Giả sử mảng chuỗi:
$full_name = '["John Doe","David Miller","Adam Smith"]';
Muốn đầu ra chuỗi đơn:
John Doe, David Miller, Adam Smith
Dùng json_decode().
Ví dụ
<!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>
Kết quả
The Result in one string=John Doe, David Miller, Adam Smith