|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2001-01-19 09:01 UTC] andrei@php.net
  [2001-01-19 11:35 UTC] instigator at openave dot com
  [2001-03-08 10:22 UTC] stas@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Wed Oct 22 14:00:01 2025 UTC | 
<?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>"; ?>