Re: Re: unexpected array_diff output

From: Date: Fri, 30 Apr 2004 10:21:49 +0000
Subject: Re: Re: unexpected array_diff output
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-185030@lists.php.net to get a copy of this message
"Frederic Noyer" <phphraban@noyer.ch> wrote in message news:DA5AC61A-9A8C-11D8-B06A-000A95A78AFC@noyer.ch... > > On 30 avr. 04, at 11:31, Torsten Roehr wrote: > > > "Frederic Noyer" <phphraban@noyer.ch> wrote in message > > news:3AE4478C-9A88-11D8-B06A-000A95A78AFC@noyer.ch... > >> > >> On 30 avr. 04, at 11:00, Torsten Roehr wrote: > >>>> > >>> > >>> I think this is correct because the 3 key/value pairs from the first > >>> array > >>> are NOT in the second one. I think the combination of key and value > >>> are > >>> relevant for array_diff(). > >> > >> As I have understand only the array_diff_assoc function does that. > >> see php.net: > >> > >> "Description > >> array array_diff_assoc ( array array1, array array2 [, array ...]) > >> > >> array_diff_assoc() returns an array containing all the values from > >> array1 that are not present in any of the other arguments. Note that > >> the keys are used in the comparison unlike array_diff()." > > > > So array_diff() seems to be for arrays where the key is not defined so > > that > > only values are recognized. > > > > Regards, Torsten > > Any ideas what this implies in termes of code ? > You mean, I should not fill my array with values this way ? > "$arr2[] = (string) $recListAut['aut_id'];" If the keys are not important for you that would be the way to do it, although I don't think you need (string). If the keys are important you should use array_diff_assoc(). Regards, Torsten > > Because this is precisely the way to fill it without specifying the > key. see www.php.net: > http://ch2.php.net/manual/en/language.types.array.php > > Regards, Fred

« previous php.general (#185030) next »