-1

Arrays always blow my mind and even the simplest tasks sometimes seem impossible!

I need to read the value of [total] from [exact_matches]. How do I do it?

$result = Array ( 
           [exact_matches] => Array ( 
                [total] => 0 
                [members] => Array ( ) 
           ),
           [full_search] => Array ( 
                [total] => 1 
                [members] => Array ( ) 
           ) 
        ) 

Thanks in advance for any help!

Amarnasan
  • 14,939
  • 5
  • 33
  • 37
Richard Tinkler
  • 1,635
  • 3
  • 21
  • 41

2 Answers2

0

For level one you would do,

$total = $result['exact_matches']['total']; which would return 0; 

for the second total

$total = $result['exact_matches']['full_search']['total'] 

which would return 1;

RossW
  • 149
  • 7
-1

First Total:

echo $result['exact_matches']['total'];

Second Total:

echo $result['exact_matches']['total']['full_search']['total'];

I don't know which total do you want

aldrin27
  • 3,407
  • 3
  • 29
  • 43