Hi guys, i have an array structured like:
$something = array(
0 => array(
'label' => 'Foo',
'items' => array(
'123' => 4,
'124' => 0,
)
),
1 => array(
'label' => 'Bar',
'items' => array(
'125' => 5,
'126' => 1,
)
),
2 => array(
'label' => 'Baz',
'items' => array(
'127' => 0,
'128' => 0,
)
)
);
And i need to remove all the 'items' key with value zero, and if an items have no childs, remove the entire block.
So, after filtering that array, i should have:
array(2){
[0]=>
array(2) {
["label"]=> "Foo"
["items"]=>
array(1) {
[123]=> 4
}
}
[1]=>
array(2) {
["label"]=> "Bar"
["items"]=>
array(2) {
[125]=> 5
[126]=> 1
}
}
}
I've tryed using array_filter, array_walk and array_walk_recursive (this one works good - but - doesnt allow me to remove the keys in the callback function..) without success..
Have i to deconstruct and rebuild in a new one array, or am I missing the right use of array_* functions?