From:             [EMAIL PROTECTED]
Operating system: Linux
PHP version:      4.2.3
PHP Bug Type:     Strings related
Bug description:  str_replace

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: [EMAIL PROTECTED]
Phone: +32 067/48 58 94
Mobile: +32 (0)472 95 15 48
Web: http://www.panacode.com
-- 
Edit bug report at http://bugs.php.net/?id=20221&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=20221&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=20221&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=20221&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=20221&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=20221&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=20221&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=20221&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=20221&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=20221&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=20221&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20221&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=20221&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=20221&r=isapi

Reply via email to