How to get key-value of JSON array outside of the loop using PHP

For example, this is a simple array you How to get key-value of JSON array outside of the loop using PHP have:

$json_data = {"name":"John","age":30};

First, you need to decode it:

$arr = json_decode($json_data, true);

Create an array variable for using this array variable outside the loop:

 $i = array();

Get the key value of the Json array by loop and assign the value in $i array variable:



foreach($arr as $key=>$value){
    $i[] = $value;

}

Now you can use $i value outside the loop:

echo $final_update_id = $i[0];

//example = john

How to get key value of JSON array outside of the loop using phpexpoundsofttechsolution Event Methods in jQuery