#8218 [Opn->Asn]: str_replace() with count of replacements

From: Date: Sun, 13 Apr 2003 22:10:22 +0000
Subject: #8218 [Opn->Asn]: str_replace() with count of replacements
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-37617@lists.php.net to get a copy of this message
ID: 8218 Updated by: pollita@php.net Reported By: Dante at altmuehlnet dot de -Status: Open +Status: Assigned Bug Type: Feature/Change Request Operating System: Any PHP Version: 4.0.3pl1 Assigned To: pollita Previous Comments: ------------------------------------------------------------------------ [2000-12-12 21:45:38] Dante at altmuehlnet dot de 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 this bug report at http://bugs.php.net/?id=8218&edit=1

« previous php.bugs (#37617) next »