I have this multi-dimensional array and I want to delete completely if the [earnings] index are empty.
Array
(
[0] => Array
(
[earnings] =>
[other] => Array()
[ord] => 2
[days] => 1
[total] => 1
)
[1] => Array
(
[earnings] => The campaign was effectively ended in November 1917.
[other] => Array
(
[campaign] => 1
[novemb] => 1
[today] => 1
)
[ord] => 1
[days] => 8
[total] => 1
)
)
I like to output something like this:
[1] => Array
(
[earnings] => The campaign was effectively ended in November 1917.
[other] => Array
(
[campaign] => 1
[novemb] => 1
[today] => 1
)
[ord] => 1
[days] => 8
[total] => 1
)
I tried this but not doesn't work quite well:
foreach($array as $key=>$test){
foreach($test as $koval=>$user) {
if( empty($user['earnings']) || !file_exists($staff['earnings'])) {
unset($array[$key][$koval]); }}}