I've set up an array of associative arrays (with dummy data for testing) like this:
// To hold dropdown filter options
$results['filters'] = array('Client' => array( array('a' => '1') ),
'Project' => array( array('b' => '2') ),
'Status' => array( array('c' => '3') ),
'User' => array( array('d' => '4') )
);
Can anyone tell me why this works:
// Add 'All' option to the top of each filter dropdown
foreach($results['filters'] as $filter_key => $filter_value) {
$results['filters'][$filter_key][] = array('name' => 'All');
}
But this doesn't:
// Add 'All' option to the top of each filter dropdown
foreach($results['filters'] as $filter_key => $filter_value) {
$filter_value[] = array('name' => 'All');
}
When I do print_r($results)
inside the the loop it appears to be working (appending the row to existing data), but checking it outside of the loop makes it seem like the loop has has no effect on the arrays.
Thanks