I want to iterate the keys of JSON:
{
 "rates":
 {
  "AED":4.089781,
  "AFN":85.578915,
  "ALL":121.871136
 }
}
like:
key[0] = AED
key[1] = AFN .... and so on..
Or in a foreach loop
How do I do that?
I want to iterate the keys of JSON:
{
 "rates":
 {
  "AED":4.089781,
  "AFN":85.578915,
  "ALL":121.871136
 }
}
like:
key[0] = AED
key[1] = AFN .... and so on..
Or in a foreach loop
How do I do that?
 
    
     
    
    Use json_decode() in combination with forEach()
$j = json_decode('{
    "rates": {
        "AED":4.089781,
        "AFN":85.578915,
        "ALL":121.871136
    }}
');
foreach($j->rates as $key => $tmp) {
  echo $key . PHP_EOL;
}
# AED AFN ALL
