0

I have question about calling array multidimensional.
I have array like this

array(1) { ["month"]=> array(2) { 
["January"]=> array(4) { [0]=> array(1) { [1]=> string(4) "2100" } [1]=> array(1) { [2]=> string(2) "50" } [2]=> array(1) { [3]=> string(4) "7858" } [3]=> array(1) { [4]=> string(4) "3535" } } 
["December"]=> array(2) { [0]=> array(1) { [1]=> string(3) "123" } [1]=> array(1) { [2]=> string(4) "1900" } } } }

if I convert to json_encode, like this:

string(111) "{"month":{"January":[{"1":"2100"},{"2":"50"},{"3":"7858"},{"4":"3535"}],"December":[{"1":"123"},{"2":"1900"}]}}" 

"month" have 2 element right? (January and December)
and January have 4 element;

question is: How to call array month with value January and December without child value in January and December?
I think like this: array (2) => {[January][December]}

Amit Gupta
  • 2,771
  • 2
  • 17
  • 31

2 Answers2

0
array_keys($array['month']);

it will solves your problem https://eval.in/938638`

Buddy
  • 10,874
  • 5
  • 41
  • 58
NanThiyagan
  • 552
  • 6
  • 13
0

Specific to your question use : array_keys($array['month']);