मान लें कि निम्नलिखित हमारी स्ट्रिंग सरणी है -
$full_name= '["John Doe","David Miller","Adam Smith"]';
हम एक ही स्ट्रिंग में आउटपुट चाहते हैं -
John Doe, David Miller, Adam Smith
इसके लिए json_decode() का इस्तेमाल करें।
उदाहरण
PHP कोड इस प्रकार है
<!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> आउटपुट
यह निम्नलिखित आउटपुट उत्पन्न करेगा
The Result in one string=John Doe, David Miller, Adam Smith