I am trying to unset array item in my multidimensional array. However the approach is working for only first loop (which is not my case) in second loop unset doesn't work.
I have tried to find here but unable to get the result with those resolution. So eventually posting with new thread.
$arr = [
'subnav' => [
'first' => [
'one' => 'hello',
'two' => 'Jatin',
'admin' => TRUE,
],
'second' => [
'one' => 'hello',
'two' => 'Priya',
'admin' => FALSE,
],
],
'pagenav' => [
'cook' => [
'one' => 'hello',
'two' => 'Rahul',
'admin' => TRUE,
],
'driver' => [
'one' => 'hello',
'two' => 'Vijay',
'admin' => TRUE,
],
],
];
foreach ( $arr as $floop => $fval ) {
foreach ( $fval as $nav => $item ) {
if ( $item[ 'admin' ] == FALSE ) {
unset( $fval[ $nav ] );
}
}
}
So here I want to remove every item which has admin => false