Bug #18315 Updated: Different behaviour of array_diff in a variables and encapsuled with each

From: Date: Fri, 12 Jul 2002 17:09:38 +0000
Subject: Bug #18315 Updated: Different behaviour of array_diff in a variables and encapsuled with each
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-13998@lists.php.net to get a copy of this message
ID: 18315 Updated by: cirello@estadao.com.br Reported By: cirello@estadao.com.br Status: Bogus Bug Type: Arrays related Operating System: Linux Red Hat Linux release 7.1 PHP Version: 4.2.1 New Comment: OK, if it is not a bug on array_diff there must be some problem somewhere. A deeper look on the possibilities I understand that the problem might be layed on each function. Anyway I shall discuss it on newsgroup first... Then I'll apply for another bug check or not. Thank you. Carlos Cirello Previous Comments: ------------------------------------------------------------------------ [2002-07-12 13:03:10] cynic@php.net one more note: array_diff() is not a generator, and it's run as many times as it returns non-false, IOW in this case forever. ------------------------------------------------------------------------ [2002-07-12 13:01:28] cynic@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php ------------------------------------------------------------------------ [2002-07-12 10:39:59] cirello@estadao.com.br /* Two arrays do diff */ $array_one = Array(1,2,3); $array_two = Array(1,2); /* Bugged behaviour*/ while( list(,$value) = @each(array_diff($array_one, $array_two)) ) echo $value."\n"; /* But this while loop never ends ... If the array_diff returns just one value , why is it never ending?*/ /* WorkAround */ $array_diffed = array_diff($array_one, $array_two); while( list(,$value) = @each($array_diffed) ) echo $value."\n"; ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18315&edit=1

« previous php.bugs (#13998) next »