PHP 4.0 Bug #8794: preg_grep changed behavior by design?
| From: | instigator at openave dot com | Date: | Fri, 19 Jan 2001 01:27:48 +0000 |
| Subject: | PHP 4.0 Bug #8794: preg_grep changed behavior by design? | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-44518@lists.php.net to get a copy of this message | ||
From: instigator@openave.com
Operating system: GNU/Linux
PHP version: 4.0.4pl1
PHP Bug Type: PCRE related
Bug description: preg_grep changed behavior by design?
<?php
# The behavior of preg_grep() changed, seems to be broken.
# Don't know if it is a preg_grep() change or a Zend hash change.
# Indexing bug is my guess, or RedHat 7.0.
# Or maybe by design (see NEWS)
# Here is a test case for reproduction.
# Set up an array of strings.
$a = array( "foo", "bar", "baz" );
# Display them all first, FYI.
for( $bug = 0; $bug < count( $a ); $bug++ )
{
echo "test: ".$a[$bug]."<br>";
}
# This works as expected, [0] is result, [1] is whatever.
$b = preg_grep( "/^foo/", $a );
echo "try to find foo as [0]: ".$b[0]." count=".count( $b
)."<br>";
echo "try to find foo as [1]: ".$b[1]." count=".count( $b
)."<br>";
# This fails as unexpected, [0] is whatever, [1] is result????
$b = preg_grep( "/^bar/", $a );
echo "try to find bar as [0]: ".$b[0]." count=".count( $b
)."<br>";
echo "try to find bar as [1]: ".$b[1]." count=".count( $b
)."<br>";
?>
--
Edit Bug report at: http://bugs.php.net/?id=8794&edit=1