JSON Encode and Decode using PHP

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);

Leave a Comment

Cancel reply

Your email address will not be published.