-1

I have this JSON file.

{
  "2438": {
    "open": false,
    "tag": "borci1",
  },
  "2210": {
    "open": false,
    "tag": "Jeskinky",
  },
}

I know how to get eg. "tag" or "open", but how can I get "2438" and "2210" ?

Eakethet
  • 682
  • 1
  • 5
  • 18
  • `$arr['2438']` isn't it? – Yogesh Suthar Jun 21 '13 at 11:34
  • Can this answer help you out? http://stackoverflow.com/questions/4343596/parsing-json-file-with-php – Duikboot Jun 21 '13 at 11:34
  • Just spend some time on php.net... in particular the pages that deal with loops and browse the list of [array functions in php](http://php.net/manual/en/ref.array.php), 79 functions in total, there's bound to be one in there that deals with `array_keys`. After that, please [read the FAQ](http://stackoverflow.com/faq), to understand why this isn't a good SO question – Elias Van Ootegem Jun 21 '13 at 11:45

2 Answers2

1

after parsing json with json_decode use foreach

foreach($json as $key=>$value)
{
//$key is the index of array
}
Ali Akbar Azizi
  • 3,272
  • 3
  • 25
  • 44
1
$json_arr=json_decode($string,true);
print_r( array_keys($json_arr) );
Goutam Pal
  • 1,763
  • 1
  • 10
  • 14