From:             admin at ifyouwantblood dot de
Operating system: Windows XP
PHP version:      5.2.5
PHP Bug Type:     PCRE related
Bug description:  preg_grep messes up array index

Description:
------------
preg_grep messes up the given array.

Reproduce code:
---------------
<?php

$array=Array(1,2,3);

debug_zval_dump($array); echo "<br>\n";

debug_zval_dump(preg_grep('/asdf/',$array)); echo "<br>\n";

while(list($key,$value)=each($array)) echo "Array: ".$value." ";

echo "<br>\n";

debug_zval_dump($array); echo "<br>\n";

?>

Expected result:
----------------
array(3) refcount(2){ [0]=> long(1) refcount(1) [1]=> long(2) refcount(1)
[2]=> long(3) refcount(1) } 
array(0) refcount(1){ } 
Array: 1 Array: 2 Array: 3 
array(3) refcount(2){ [0]=> long(1) refcount(1) [1]=> long(2) refcount(1)
[2]=> long(3) refcount(1) } 

Actual result:
--------------
----PHP6 Build Jan 20 2008 18:04:22----
array(3) refcount(2){ [0]=> long(1) refcount(1) [1]=> long(2) refcount(1)
[2]=> long(3) refcount(1) } 
array(0) refcount(1){ } 

array(3) refcount(2){ [0]=> long(1) refcount(1) [1]=> long(2) refcount(1)
[2]=> long(3) refcount(1) } 

-----PHP5.2.5
array(3) refcount(2){ [0]=> long(1) refcount(1) [1]=> long(2) refcount(1)
[2]=> long(3) refcount(1) } 
array(0) refcount(1){ } 

array(3) refcount(2){ [0]=> string(1) "1" refcount(1) [1]=> string(1) "2"
refcount(1) [2]=> string(1) "3" refcount(1) } 

-- 
Edit bug report at http://bugs.php.net/?id=44191&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44191&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44191&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44191&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44191&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44191&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44191&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44191&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44191&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44191&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44191&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44191&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44191&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44191&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44191&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44191&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44191&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44191&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44191&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44191&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44191&r=mysqlcfg

Reply via email to