How to remove a character (‘’) in string array and display result in one string php?

PHPServer Side ProgrammingProgramming

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

 Live Demo

<!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
raja
Published on 13-Oct-2020 08:40:55
Advertisements