php fetch json data code example
Example 1: how to receive json data in php
$data = json_decode(file_get_contents('php://input'), true);
print_r($data);
echo $data;
Example 2: fetch value from json link in php
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'url_here');
$result = curl_exec($ch);
curl_close($ch);
$obj = json_decode($result);
echo $obj->access_token;
Example 3: how to get data from json array in php
$data = json_decode($json);