json_encode & json_decode functions
<?php
$data = [
'name' => 'John',
'scores' => [95, 60, 75],
];
$jsonStr = json_encode($data);
echo $jsonStr.PHP_EOL;
$data = json_decode($jsonStr, true);
print_r($data);
<?php
$data = [
'name' => 'John',
'scores' => [95, 60, 75],
];
$jsonStr = json_encode($data);
echo $jsonStr.PHP_EOL;
$data = json_decode($jsonStr, true);
print_r($data);
Leave a Comment
Cancel reply