note 109554 deleted from function.str-replace by danbrown
| From: | danbrown@php.net | Date: | Mon, 30 Jul 2012 15:49:15 +0000 |
| Subject: | note 109554 deleted from function.str-replace by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189481@lists.php.net to get a copy of this message | ||
Note Submitter: bfrohs at gmail dot com
----
My previous not about str_replace_limit()
(http://www.php.net/manual/en/function.str-replace.php#109365) has a bug in the code at the
beginning of the function. The corrected snippet:
<?php
function str_replace_limit($search, $replace, $subject, &$count, $limit = -1){
$count = 0;
// Invalid $limit provided
if(!($limit===strval(intval(strval($limit))))){
trigger_error('Invalid $limit
'.$limit.' provided. Expecting an
'.
'integer', E_USER_WARNING);
return $subject;
}
// Invalid $limit provided
/* ... */
?>
A more documented (and bug-free) version can also be found at http://stackoverflow.com/a/11400172/526741