
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 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