I have the following PHP array (this is a simplified version for illustration) $myarray
:
Array
(
[0] => Array
(
[firstName] => Zaphod
[show_nav] => yes
[lastName] => Beeblebrox
)
[1] => Array
(
[firstName] => Ford
[show_nav] =>
[lastName] => Prefect
)
[2] => Array
(
[firstName] => Arthur
[show_nav] => yes
[lastName] => Dent
)
[3] => Array
(
[firstName] => Tricia
[show_nav] =>
[lastName] => McMillan
)
)
I need to remove the entries where show_nav
is not set to yes
, and produce a new array with the results. So afterwards it would look like this - $myarray
:
Array
(
[0] => Array
(
[firstName] => Zaphod
[show_nav] => yes
[lastName] => Beeblebrox
)
[1] => Array
(
[firstName] => Arthur
[show_nav] => yes
[lastName] => Dent
)
)
The array can be any length, with show_nav
being set to yes for any number of entries. I know how to remove specific entries, but I am not sure how to look through the array and remove entries based on the values.
Any help greatly appreciated!