RE: array_diff()?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Thiago H. Pojda [mailto:thiago.pojda@xxxxxxxxx]
> Sent: Wednesday, June 25, 2008 3:10 PM
> To: php-general@xxxxxxxxxxxxx
> Subject:  array_diff()?
> 
> *accidentally sent*
> 
> Guys,
> 
> Perhaps I'm missing something or just trying with the wrong tools...
> 
> But the thing is, I have two arrays and want to know what values are
in
> one
> that aren't in the other.
> 
> They're very long arrays (label files for translation) and the
> array_diff()
> is returning null, even if I force a difference.
> 
> What's up?
> 
> <?php
> $file1 = 'label_es.ini';
> $file2 = 'label_pt.ini';
> 
> $fh1 = fopen ($file1,'r');
> $fh2 = fopen ($file2,'r');
> 
> $file1 = array();
> $file2 = array();
> 
> while (($line = fgets($fh1))) {
>     $label = explode("=",$line);
>     $array1[] = $label[0];
> }
> 
> while (($line = fgets($fh2))) {
>   $label = explode("=",$line);
>   $array2[] = $label[0];
> }
> 
> 
> $missingLabels= array_diff($array1,$array2);
> 
> 
> var_dump($labelsFaltantes); // returns nothing
> var_dump($array1); // returns a lot of stuff
> var_dump($array2); // returns a lot of stuff
> ?>

Umm...

Is $missingLabels supposed to be what you're var_dump()ing later in the
code? Cuz you call it $labelsFaltantes almost immediately after, which
has not been defined (by what I can see).


Todd Boyd
Web Programmer

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux