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