Removing Array values From Another Array?! It's Driving Me Insane!!
Can anyone tell me how to remove one array from another, its driving me insane!!!
I have a two arrays and i want to remove the values from the first if they exist in the second...
$myArrayToRemove = array('23', '12', '3');
$myArray2removeFrom = array('4', '5', '23', '12', '7', '3');
So i would get the result... $finishArray('4', '5', '7');
The order doesn't matter if that's a problem, i've managed to get some results using the explode / join method here... http://lixlpixel.org/php-benchmarks/.../#foreach-loop
But it seems to always leave one value in the array even if the array should be left empty.
Any suggestions would be greatly appreciated, i've been trying for ages arrgghhh lol!
No need to go insane or use needlessly complex, custom built functions. Just use php.net:
Absolute life saver!! ha. I've looked at that page so many times while searching too, but i was using echo instead of print_r so it was only giving me 'Array' which was confusing me i think.
I'm glad its so simple! I've been coding stupidly long functions for the last 2 days to try make it work. thanks for the quick reply as well!
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)