Re: Array differences
| From: | Nathan Rixham | Date: | Wed, 14 Apr 2010 10:03:47 +0000 |
| Subject: | Re: Array differences | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-304085@lists.php.net to get a copy of this message | ||
Ashley Sheridan wrote:
> On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote:
>>
>> However what I really want is a two-way comparison. I want elements that
>> don't exist in either to be returned:
>>
>
>
> I don't see any problems with doing it that way.
By some freak chance I made an array diff class about 2 weeks ago which
covers what you need. attached :)
usage:
$diff = new ArrayDiff( $old , $new );
$diff->l; // deleted items
$diff->r; // inserted items
$diff->u; // unchanged items
The script is optimised for huge arrays, thus it's slower for small
arrays than the usual array_diff but with large arrays it's quicker.
Regards
Nathan