|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-12-26 13:18 UTC] team at fazend dot com
Description:
------------
RegexIterator::REPLACE doesn't work as it is supposed to do. The code
example attached should return something, but it returns nothing.
Reproduce code:
---------------
$i = new RegexIterator(
new ArrayIterator(array(
'test1'=>'test888',
'test2'=>'what?',
'test3'=>'test999')),
'/^test(.*)/',
RegexIterator::REPLACE);
foreach ($i as $name=>$value)
echo $name . '=>' . $value . "\n";
Expected result:
----------------
888
999
Actual result:
--------------
nothing
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 02:00:01 2025 UTC |
Hi, i saw the test file (bug50579.phpt), it's strange to put the replacement property on the iterator parameter insteed the Regexiterator instance, imagine i've this follow code : class foo extends ArrayIterator { public function __construct( ) { parent::__construct(array( 'test1'=>'test888', 'test2'=>'what?', 'test3'=>'test999', 'replacement' => 'replacement'), ArrayIterator::ARRAY_AS_PROPS); $this->replacement = '[$1]'; } } if a would read $h->replacement, i've '[$1]' insteed 'replacement'. it's more logical to do : $i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE); $i->replacement = '[$0]'; or maybe make a methode : $i->setReplacement('[$0]');