-1

I've finally figured out how to fetch data from Google Analytics to website, unfortunately output (print_r) is PHP array inside an array:

Array ( [0] => Array ( [0] => 196 ) )

I need to get the number 196 & "save" it as variable in order to use it in calculations or output it, any ideas how to achieve this?

Im looking for overall solution/principle/rule because some data is even array inside array inside array etc.

Solo
  • 6,687
  • 7
  • 35
  • 67

2 Answers2

1

Use this:

$newVariable = $yourArray[0][0];

echo $newVariable; //This will echo the answer.

//This answer is self explanatory.
aldrin27
  • 3,407
  • 3
  • 29
  • 43
1

you need to grab the first array element -position 0 - and from this inner array you pick the first element - also position 0 - which is 196, Check this: PHP Fiddle - hit run to execute

// getting 196
echo $myArr[0][0];
Mi-Creativity
  • 9,554
  • 10
  • 38
  • 47