06-25-2009, 09:48 PM
|
#10 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
I prefer that way using array_diff. It is a handy function. Otherwise either array_keys or array_search works just as well as one another.
Was it coincidence that your array outputs as ABBA?
One thing somebody might want though is to rebuild the indexes once some items have been removed. Therefore all the indexes now increment nicely again.
php Code:
$array = array('a', 'b', 'c', 'd', 'c', 'b', 'a'); $remove = array('c', 'd', 'f', 'Bleh'); // or just, 'c'$array = array_diff($array, (array) $remove); $array = array_values($array); // restores the indexesprint_r($array);
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|