PHP 4.0 Bug #8218: str_replace() with count of replacements
| From: | Dante at altmuehlnet dot de | Date: | Wed, 13 Dec 2000 02:45:38 +0000 |
| Subject: | PHP 4.0 Bug #8218: str_replace() with count of replacements | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-41112@lists.php.net to get a copy of this message | ||
From: Dante@altmuehlnet.de
Operating system: Any
PHP version: 4.0.3pl1
PHP Bug Type: Feature/Change Request
Bug description: str_replace() with count of replacements
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])
--
Edit Bug report at: http://bugs.php.net/?id=8218&edit=1