[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    Re: [PHP] Array_diff problems
From:       Rick Dwyer <rpdwyer () earthlink ! net>
Date:       2012-04-27 22:52:03
Message-ID: 8AC2A250-522A-43AB-97B7-17693C79585F () earthlink ! net
[Download RAW message or body]

Thanks to both for the direction.


 
 --Rick
On Apr 27, 2012, at 4:13 PM, Jim Giner wrote:

> 
> 
> Are these arrays nested in an array?  In that case the manual says you have 
> to do the compare differently.


On Apr 27, 2012, at 4:19 PM, admin wrote:

> 
> 
> -----Original Message-----
> From: Rick Dwyer [mailto:rpdwyer@earthlink.net] 
> Sent: Friday, April 27, 2012 3:37 PM
> To: PHP-General
> Subject: [PHP] Array_diff problems
> 
> Hello all.
> 
> I have two arrays and when compared against each other via array_diff, I do
> not get any output:
> 
> $myarray1 = Array (
> [0] => Array ( [id] => 1 [Funding_Type] => Federal [Amount] => 10
> [Frequency_Description] => Total [Other_Funding] => ) [1] => Array ( [id] =>
> 2 [Funding_Type] => Trust [Amount] => 20 [Frequency_Description] => Per Year
> [Other_Funding] => ) [2] => Array ( [id] => 3 [Funding_Type] => Other
> Funding [Amount] => 30 [Frequency_Description] => Other [Other_Funding] =>
> some )) 
> 
> $myarray2 = Array
> (
> [0] => Array ( [id] => 1 [Funding_Type] => Federal [Amount] => 10
> [Frequency_Description] => Total [Other_Funding] => ) [1] => Array ( [id] =>
> 2 [Funding_Type] => Trust [Amount] => 20 [Frequency_Description] => Per Year
> [Other_Funding] => ) [2] => Array ( [id] => 3 [Funding_Type] => Other
> Funding [Amount] => 50 [Frequency_Description] => Other [Other_Funding] =>
> none )) 
> 
> $arraydifferences = (array_diff($myarray1,$myarray2));
> 
> I need $arraydifferences to record the differences between the two.
> 
> Any help is appreciated.
> 
> Thanks,
> 
> --Rick
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
> 
> 
> 
> I suggest you read Multidimensional array_diff for Nested Arrays and your
> format is not correct on the array that you gave an example of.
> 
> http://www.php.net/manual/en/function.array-diff.php#98680
> 
> 
> 
> 
> 
> 
> 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic