0

Actual JSON Object

[[["पिता का नाम","Father's name",null,null,1] ,[null,null,"pita ka naam"] ] ,null,"en",null,null,[["Father's name",null,[["पिता का नाम",1000,true,false] ] ,[[0,13] ] ,"Father's name",0,0] ] ,1.0,[] ,[["en"] ,null,[1.0] ,["en"] ] ]

After doing json_decode; i am getting below result. i want to access first value which is in Hindi(INDIAN LANGUAGE)

Array ( [0] => Array ( [0] => Array ( [0] => पिता का नाम [1] => Father's name [2] => [3] => [4] => 1 ) [1] => Array ( [0] => [1] => [2] => pita ka naam ) ) [1] => [2] => en [3] => [4] => [5] => Array ( [0] => Array ( [0] => Father's name [1] => [2] => Array ( [0] => Array ( [0] => पिता का नाम [1] => 1000 [2] => 1 [3] => ) ) [3] => Array ( [0] => Array ( [0] => 0 [1] => 13 ) ) [4] => Father's name [5] => 0 [6] => 0 ) ) [6] => 1 [7] => Array ( ) [8] => Array ( [0] => Array ( [0] => en ) [1] => [2] => Array ( [0] => 1 ) [3] => Array ( [0] => en ) ) )

Phil
  • 157,677
  • 23
  • 242
  • 245
Zoobi
  • 41
  • 8

1 Answers1

2

You can access properties of an array by index. The index starts at 0 being the first position then 1, and so on.

$arr = ['a','b','c'];

 echo $arr[0]; //Output is 'a'
 echo $arr[1]; //Output is 'b'

If you have a multi-dimensional array you just access the first property of the first array and then the second property of the second array like so:

$arr = [
     ['a','b','c'],
     ['d','e','f']
];
echo $arr[0][2]; //Output is 'c'

Note: in this example, $arr[0] is the first array holding a,b & c.

In your exact example, it looks like there are 4 nested arrays, so to get the Hindi text it would be:

echo $arr[0][0][0][0];
DanielRead
  • 2,288
  • 1
  • 23
  • 34