Re: Array differences
| From: | Ashley M. Kirchner | Date: | Wed, 14 Apr 2010 14:29:42 +0000 |
| Subject: | Re: Array differences | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-304087@lists.php.net to get a copy of this message | ||
On 4/14/2010 2:39 AM, Ashley Sheridan wrote:
On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote:I don't see any problems with doing it that way. This will only work as you intended if both arrays have the same number of elements I believe, otherwise you might end up with a situation where your final array has duplicates of the same number: $array1 = $array(1, 2, 3, 4, 5, 6); $array2 = $aray(1, 3, 2, 5);$array1 = array("12", "34", "56", "78", "90"); $array2 = array("12", "23", "56", "78", "89");$diff1 = array_diff($array1, $array2); $diff2 = array_diff($array2, $array1);$result = array_unique(array_merge($diff1, $diff2));print_r($result);
Wouldn't array_unique() take care of that though? Your example above returns 4 and 6, which would be correct.
A