![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
PHP How to add backslash inside array of strings?\n
To add backslash inside array of strings, use json_encode().
Let’s say the following is our array −
$value = [ "ADD", "REMOVE","SELECT","MODIFY" ];
We want the output with backslash inside array of strings i.e −
"[\"ADD\",\"REMOVE\",\"SELECT\",\"MODIFY\"]"
Example
The PHP code is as follows −
<!DOCTYPE html> <html> <body> <?php $value = [ "ADD", "REMOVE","SELECT","MODIFY" ]; echo json_encode(json_encode($value)) . "
"; ?> </body> </html>
Output
This will produce the following output
"[\"ADD\",\"REMOVE\",\"SELECT\",\"MODIFY\"]"
Advertisements