Page 1 of 1

[SOLVED] Delete from an array

Posted: Thu Aug 09, 2007 7:41 am
by Stryks
I always get myself into trouble asking these questions, but anyhow ...

Is there any function for deleting an array from an array?

Like ...

Code: Select all

$arr1 = array("apple", "pear", "orange", "small one eyed dog");
$arr2 = array("orange", "apple");

print_r(array_blah($arr1, $arr2));
... giving output of something like ...
array([0]=>"pear" [1]=>"small one eyed dog")
Failing a function like this, I guess I'll just do an array_search and unset any matches, but I cant find a function or an alternate clean way of doing this, and though I've searched, I havent found anything much.

Cheers

Posted: Thu Aug 09, 2007 7:45 am
by Stryks
See .... :oops:

array_diff seems to do the job quite neatly.

Cheers anyway all 8)