Skip to content Skip to sidebar Skip to footer

Accessing Specific Json Value

I currently have a variable $return which contains JSON-encoded data, which prints out as: ({0:{data:[[0, null], [1, null], [2, null], [3, null], [4, null], [5, null], [6, null], [

Solution 1:

Have you tried using http://www.php.net/json_decode to turn your JSON into an array and then access the elements as you would a normal array?

Solution 2:

$return=json_decode($return);
if($return['data'][0]){
// what to do if null
}else{
// what to do if not (alternatively use elseif())
}

Solution 3:

there is a function called json_decode(). it will simply return you original array of json string..

$ary = array(); 
$ary = json_decode($json_string);
echo"<pre>";print_r($ary);echo"</pre>";

Post a Comment for "Accessing Specific Json Value"