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
How to remove a character (‘’) in string array and display result in one string php?
Let’s say the following is our string array −
$full_name= '["John Doe","David Miller","Adam Smith"]';
We want the output in a single string −
John Doe, David Miller, Adam Smith
For this, use json_decode().
Example
The PHP code is as follows
<!DOCTYPE html>
<html>
<body>
<?php
$full_name= '["John Doe","David Miller","Adam Smith"]';
$full_name = json_decode($full_name);
$filterData = array_filter(array_map('trim', $full_name));
$output = implode(', ', $filterData);
echo "The Result in one string=",$output;
?>
</body>
</html>
Output
This will produce the following output
The Result in one string=John Doe, David Miller, Adam Smith
Advertisements