Giả sử sau đây là mảng chuỗi của chúng ta -
$full_name= '["John Doe","David Miller","Adam Smith"]';
Chúng tôi muốn đầu ra trong một chuỗi duy nhất -
John Doe, David Miller, Adam Smith
Đối với điều này, hãy sử dụng json_decode ().
Ví dụ
Mã PHP như sau
<!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> Đầu ra
Điều này sẽ tạo ra kết quả sau
The Result in one string=John Doe, David Miller, Adam Smith