ID: 18199 Comment by: richard at bowmansystems dot com Reported By: webmaster at aglaea dot net Status: Bogus Bug Type: Arrays related Operating System: Linux PHP Version: 4.1.2 New Comment:
Bug still present in 4.2.3. Just because you are to lazy to verify it doesn't mean you should mark it as bogus. The test case is trivial, why not just try it? <php $blah = array (); $blah[1] = null; $blah[2] = array(); is_array( $blah[1] ); //returns FALSE as you would expect is_array( $blah[2] ); //BUG! returns FALSE, should be TRUE $foo = $blah[2]; is_array( $foo ); //returns TRUE, this is the work-around Previous Comments: ------------------------------------------------------------------------ [2002-09-11 11:33:53] [EMAIL PROTECTED] Thank you for taking the time to report a problem with PHP. Unfortunately you are not using a current version of PHP -- the problem might already be fixed. Please download a new PHP version from http://www.php.net/downloads.php If you are able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PHP. ------------------------------------------------------------------------ [2002-08-28 01:01:34] yzhu at ou dot edu I just upgraded to php-4.1.2 on RHL 7.2. Before this I was using a php-4.0.6-15, and experienced the same problem as [EMAIL PROTECTED] did (I assume). One thing should be clear about this issue is is_array fails under a particular circumtance. I encountered this problem when I have a mixed associative array like the following (actually its member's nature most likely automatically generated from some procedures, is not known before you test):(I assume the bug reporter did too) $as_ar = array( array("32"=>5, "you" =>6, "him"=>3, "her"=>2, 8, 3.4), "lone"=>19; array("red"=>"3", "yellow"=>4, "green"=>5), 28 array("east"=>2, "west"=13, "south"=>4, "north"=>5) ); Now, Try this: $keys = array_keys ($as_ar); if (is_array($as_ar[$keys[1]])){ echo "The second element is an array<br>"; } This will print the message on PHP-4.0.6-15. But on the same RHL 7.2, PHP-4.1.2 seems to be able to catch this, and the test return false. I did not test this code on any other versions However, if you believe this test result you will get into trouble. To get around this, I test the value instead the element (or keys). E.g. for this particular array I do: $theKeys = array_keys ($as_ar); $theValue = $as_ar[$theKeys[1]]; if ( is_array($theValue)){ echo "The second element is an array<br>"; } This will actually evaluate the nature of the element, not wether the element is more complex than a simple (indexed) one. I reported this finding on the PHP manual is_array page. And the editor removed it after some days. But this is a real issue, and can be confusing, frustrating too. I hope manual editors put something there to advise people how to cope with the problem. Well... ------------------------------------------------------------------------ [2002-07-06 08:02:28] [EMAIL PROTECTED] Can you provide a simple selfcontained sample script that reproduces your problem? ------------------------------------------------------------------------ [2002-07-06 07:52:28] webmaster at aglaea dot net Unless I'm dementing fast, this bit of code: $teams = $league->getTeams(); if (is_array($teams)) { array_walk($teams, 'InDiv'); } should not do the array_walk when $teams is either 'null' or '0', but in my page, it keeps on trying to do the array_walk, which obviously goes wrong. I've also tried: if ($teams) { and if ($teams != null) you can see the precise details of my PHP-version and system at www.korfballworld.com/test/info.php ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18199&edit=1