|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-19 20:04 UTC] tomlove at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 00:00:01 2025 UTC |
Description: ------------ I assume this is a feature: str_replace recursively replaces when both $search and $replace are arrays. It's too easy for this to cause runaway memory consumption though. I've never needed to take advantage of the recursive nature of the function, and wouldn't expect many others to. The code below is enough to hang my system. Reproduce code: --------------- for ($i = 0; $i < 50; $i++) { $arr1[$i] = "foo"; $arr2[$i] = "foobarfoo"; } $str = "foobar"; echo str_replace($arr1, $arr2, $str); Expected result: ---------------- Ideally: foobarfoobar Actual result: -------------- foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar....