#20221 [Opn->Fbk]: str_replace
| From: | kalowsky@php.net | Date: | Sat, 02 Nov 2002 20:22:24 +0000 |
| Subject: | #20221 [Opn->Fbk]: str_replace | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-23956@lists.php.net to get a copy of this message | ||
ID: 20221
Updated by: kalowsky@php.net
Reported By: panacode@skynet.be
-Status: Open
+Status: Feedback
Bug Type: Strings related
Operating System: Linux
PHP Version: 4.2.3
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2002-11-02 13:04:24] panacode@skynet.be
str_replace when used with with arrays,
for every element in the search/replace arrays
a simple replace in the source string (rather than
using an external string) is performed.
This causes an unexpected result like
if one of the replace values includes
a search value it will be replaced in a subsequent
replacing action.
If this is a feature rather than a bug (which I doubt)
please state it in the documentation.
An example:
$vSearch[] = '@gill';
$vSearch[] = '@doubleyou';
$vReplace[] = '@doubleyou';
$vReplace[] = '@bates';
$sSubject = "@gill is my friend";
$sResult = str_replace($vSearch, $vReplace, $sSubject);
echo $sResult;
// will output "@bates is not my friend" instead
// of "@doubleyou is not my friend"
Best regards,
Eugen Fernea
IT Manager
Panacode Software
rue de la Station, 1/1
7090 Braine-Le-Comte
Belgium
E-mail: panacode@skynet.be
Phone: +32 067/48 58 94
Mobile: +32 (0)472 95 15 48
Web: http://www.panacode.com
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20221&edit=1