How to access array element values using array-index?
<?
$json = '{
"dynamic":{
"pageCount":"12",
"tableCount":"1"
}
}';
$arr = json_decode($json, true);
echo $arr['dynamic']['pageCount']; // working
echo $arr[0]['pageCount']; // not working
?>
I will not know what is there in 'dynamic', so i want to access pageCount values dynamically?
foreachwill iterate over the array, providing both keys and values.resetwill return the first value regardless of key (you can also get the key withkey).array_valueswill replace the keys with auto-incrementing integers. What exactly is your use case?