I have a multidimensional array of the structure :
$_SESSION['array'] = array(1=>array("surname"=>"foofoo", "name"=>"foo"),2=> .... so on);
I want to delete an entry if the surname matches a given variable e.g
$surname = "foofoo";
the function should search the entire arrays if the $surname was found, delete that array
I tried looking at some answers like the one given at here and here but I could not understand them clearly, can someone show a clear method along with some good explanations and if possible links to some documentations for reading?
This should work for you:
(In this code i go trough each innerArray and each value & key from the innerArray. Then i simple check if it's the right key with the right value. If the condition is true i unset the entire array)
Output: