|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-02-20 22:16 UTC] felipe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
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) }