ID: 12367 Updated by: venaas Reported By: [EMAIL PROTECTED] Status: Open Bug Type: Arrays related Operating System: Linux Red hat 7.1 fr PHP Version: 4.0.6 New Comment: When I wrote array_diff I didn't think of this use. It worked by accident. array_diff was changed to avoid some ordering problems. The way it was there was no well defined ordering. Due to automatic type conversion, you you would have 3d < 99 < 370 < 3d. This made array_diff fail, this was fixed by always using string comparisons. That doesn't work for arrays though. I'm not sure how you would like array_diff on arrays of arrays work, and I don't plan to fix it. Maybe some- one wants to, but first of all it must be clear how it should work. Could a work around for you be to serialize the arrays? If $a is an array of arrays, you could perhaps do say $a[0] = serialize($a[0]); $a[1] = serialize($a[1])... and so on. One internal PHP solution could perhaps be to serialize an array when comparing with scalars. Not sure if I like it myself. Previous Comments: ------------------------------------------------------------------------ [2001-07-25 11:36:08] [EMAIL PROTECTED] Example of script <? echo "<html><body>\r\n"; echo "<h1>Simple array : it works</h1>\r\n<pre>\r\n"; $array1 = array('a1' => 'toto', 'b1' => 'titi', 'b2' => 'tutu', 'b3' => 'rien', 'c1' => 'zone'); $array2 = array('a2' => 'adeux', 'b5' => 'titi'); var_dump(array_diff($array1, $array2)); echo "\r\n</pre>\r\n<hr>\r\n<h1>Array of array : it doesn't work</h1>\r\n<pre>\r\n"; $array1 = array( array('a1' => 'toto', 'b1' => 'titi', 'b2' => 'tutu', 'b3' => 'rien', 'c1' => 'zone'), array('a2' => 'adeux', 'b5' => 'titi'), array('a8' => 'ahuit', 'b12' => 'avion') ); $array2 = array( array('a2' => 'adeux', 'b5' => 'titi'), array('a7' => 'asept', 'c5' => 'camion') ); var_dump(array_diff($array1, $array2)); echo "\r\n</pre></body></html>\r\n"; ?> Command line './configure' '--with-apache=../apache' '--with-zlib' '--with-bzip2' '--enable-calendar' '--with-cybermut=../cybermut' '--enable-ftp' '--with-gd=../gd' '--with-pgsql=/usr/local/psql' '--with-mysql' '--with-sablot' '--with-xml' Comment I use array_diff with array of array comming from database since version 4.0.1 without any trouble. We just migrate to version 4.0.6 tree days ago with apache 1.3.20. Congratulation for PHP. I love it :o) ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=12367&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]