I have a query that upon being JSON encoded, and print_r() looks like this:
Array
(
[response] => Array
(
[numFound] => 2392
[start] => 0
[maxScore] => 1
[docs] => Array
(
)
)
[stats] => Array
(
[stats_fields] => Array
(
[q_one] => Array
(
[min] => 0.0059
[max] => 6.0095
[count] => 2392
[missing] => 0
[sum] => 53.9131
[sumOfSquares] => 48.16448107
[mean] => 0.022538921404682
[stddev] => 0.14012800795752
[facets] => Array
(
)
)
[q_two] => Array
(
[min] => 0
[max] => 0.0075
[count] => 2392
[missing] => 0
[sum] => 17.67
[sumOfSquares] => 0.132525
[mean] => 0.0073871237458194
[stddev] => 0.00091333432809989
[facets] => Array
(
)
)
[q_three] => Array
(
[min] => 0
[max] => 0.065
[count] => 2392
[missing] => 0
[sum] => 153.14
[sumOfSquares] => 9.9541
[mean] => 0.064021739130435
[stddev] => 0.0079155641768643
[facets] => Array
(
)
)
)
)
)
Within stats >> stats_fields I want to write a foreach loop that captures the names of each header: q_one, q_two, and q_three, but I'm not sure how to do that.
I can capture the elements inside each of these 3 'headers', because their names are static, (e.g. - each one has a min and a max element)
foreach ($json['stats']['stats_fields'] as $j) {
echo $j['min']
}
but I'm not sure how to get the header names...