- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Escaping/encoding single quotes in JSON encoded HTML5 data attributes
To escape single quotes, use json_encode() to echo arrays in HTML5 data attributes.
printf('<article data-tags="%s">', htmlspecialchars(json_encode(array('html5', ...)), ENT_QUOTES, 'UTF-8'));
Or you can also using built-in
json_encode(array('html5', ...), JSON_HEX_APOS)
Advertisements