|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-04-13 18:46 UTC] magnus@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 12:00:01 2025 UTC |
What about an optional argument to str_replace which contains the count of replacements... For example: <? $text = "Foobar [b]abc[/b] def [b]ghi"; $tmp_text = str_replace("[b]", "<b>", $text, &$replace_count_open); $new_text = str_replace("[/b]", "</b>", $text, &$replace_count_close); if($replace_count_open > $replace_count_close) $new_text .= str_repeat("</b>", $replace_count_open - $replace_count_close); ?> The original definition: string str_replace (string needle, string str, string haystack) The definition with this feature: string str_replace (string needle, string str, string haystack [, int count])