I have run a SQL query that has a group by of "province and gender", the result is following array:
Array ( [province] => Helmand [gender] => Male [ppl] => 1110 )
Array ( [province] => Kandahar [gender] => Male [ppl] => 898 )
Array ( [province] => Uruzgan [gender] => Male [ppl] => 44 )
Array ( [province] => Zabul [gender] => Male [ppl] => 248 )
I know it has 4 provinces, but i assume the list is not fixed, so using anything like Switch how can i go through this array and pick the desired results.
for example: how many female are there in Helmand.
you could add to new array
example :
$new_data = array();
foreach($list_data as $key => $val)
{
$new_data[$val->province][$val->gender] = $val->ppl;
}
in your next step you can do anything with the array for example :
$result = '';
if(isset($new_data['Helmand']['Female']))
{
// here is the next step to access it through new assosiative array
$result = $new_data['Helmand']['Female'];
}
Good luck