#26426 [Opn->Bgs]: strtr translate numbers with "Array" when using replace_pairs
ID: 26426
Updated by: derick@php.net
Reported By: elias dot norstrom at lunchinfo dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux Debian 2.4.21
PHP Version: 4.3.3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You're filling the array wrongly:
$arrTransformChars['Å'] = '....
you're creating a 2d array, which is not what this function wants.
Previous Comments:
------------------------------------------------------------------------
[2003-11-26 10:30:02] elias dot norstrom at lunchinfo dot com
Description:
------------
Trying to translate swedish encoded characters with strtr function
using replace_pairs.
The function translate numbers from 0 to sizeof(replace_pairs-array) to
the string "Array".
See example to reproduce.
Reproduce code:
---------------
<?php
$strSearchWord = "abc123åpoli987654321";
$arrTransformChars[] = array('Å' => 'Å');
$arrTransformChars[] = array('Ä' => 'Ä');
$arrTransformChars[] = array('Ö' => 'Ö');
$arrTransformChars[] = array('å' => 'å');
$arrTransformChars[] = array('ä' => 'ä');
$arrTransformChars[] = array('ö' => 'ö');
echo $strSearchWord . "<br>";
$strSearchWord = strtr($strSearchWord,$arrTransformChars);
echo $strSearchWord . "<br>";
exit;
?>
Expected result:
----------------
abc123åpoli987654321
abc123åpoli987654321
Actual result:
--------------
abc123åpoli987654321
abcArrayArrayArrayåpoli9876ArrayArrayArrayArrayArray
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26426&edit=1
Thread (2 messages)