#24784 [Opn]: str_replace count paramater only counts replacements when strlen > 1
| From: | philip@php.net | Date: | Thu, 24 Jul 2003 02:23:31 +0000 |
| Subject: | #24784 [Opn]: str_replace count paramater only counts replacements when strlen > 1 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-44630@lists.php.net to get a copy of this message | ||
ID: 24784
Updated by: philip@php.net
Reported By: philip at cornado dot com
Status: Open
Bug Type: Strings related
Operating System: linux
PHP Version: 5CVS-2003-07-23 (dev)
New Comment:
Actual result is 0. The bug database didn't allow 0 as an actual or
expected result value, but does now :)
Previous Comments:
------------------------------------------------------------------------
[2003-07-23 21:14:27] philip at cornado dot com
Description:
------------
str_[i]replace() has a count parameter that returns a variable (by
reference) with a count of replacements. This is not counting when the
search string is one character in length.
Reproduce code:
---------------
<?php
$count = 0;
$str = str_replace('a', '', 'apples are good', $count);
echo $count;
?>
Expected result:
----------------
2
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24784&edit=1