RE: [PHP] unexpected array_diff output
| From: | Ford, Mike [LSS] | Date: | Fri, 30 Apr 2004 10:11:54 +0000 |
| Subject: | RE: [PHP] unexpected array_diff output | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-185031@lists.php.net to get a copy of this message | ||
On 30 April 2004 09:47, Frederic Noyer wrote:
> Hello there !
> I am trying to fill and then compare two arrays: one
> filled by a
> foreach construct, and the second by a while construct.
> I check both with a print_r to be sure that both are correctly filled
> (which seems to be the case). But then, when I try to compare
> them with
> a array_diff , the result is incoherent (at least to me...). I have
> tried several variant, but I don't understand what's wrong. Sure you
> guys can tell me where is my mistake.
>
> Here is the code:
>
> <?
>
> // creates first array (from a _POST[''] )
> foreach ($_POST['input_auteur'] AS $aut_ligne) {
> $part_ligne = explode(",",$aut_ligne);
> $arr1[] = (string) $part_ligne['2'];
> }
> echo "Array from POST :";
> print_r ($arr1);
I don't have any great insight into what appear to be your odd array_diff()
results, but try using var_dump() instead of print_r() -- it will give you
more information about *exactly* what values are stored in the arrays, and
it may just be that you'll spot an odd discrepancy.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211