#23239 [NEW]: preg_replace don(t work on multi-dimensional arrays
From: bibifoc23 at yahoo dot fr
Operating system: windows & linux
PHP version: 4CVS-2003-04-16 (stable)
PHP Bug Type: Arrays related
Bug description: preg_replace don(t work on multi-dimensional arrays
when i use p_reg_replace on multi-dimensional arrays, the utput array is
one dimensional array and so i lost data.
i get this bug when i want replace patten with a ldap result
(ldap_get_entries);
i use the latest win32 CVS (php4) and i get with php-4.2.3
<?php
# good result
$tableau = array ( "toto", "titi", "tata" );
$tableau2 = preg_replace ( '{t}', '-', $tableau );
var_dump ( $tableau2 );
echo "----------------------------------------------\n";
# wrong result
$tableau = array ( array ("toto"), array ("titi"), array ("tata") );
var_dump ( $tableau );
$tableau2 = preg_replace ( '{t}', '-', $tableau );
var_dump ( $tableau2 );
?>
the output is:
array(3) {
[0]=>
string(4) "-o-o"
[1]=>
string(4) "-i-i"
[2]=>
string(4) "-a-a"
}
---------------------------------------------
array(3) {
[0]=>
array(1) {
[0]=>
string(4) "toto"
}
[1]=>
array(1) {
[0]=>
string(4) "titi"
}
[2]=>
array(1) {
[0]=>
string(4) "tata"
}
}
array(3) {
[0]=>
string(5) "Array"
[1]=>
string(5) "Array"
[2]=>
string(5) "Array"
}
--
Edit bug report at http://bugs.php.net/?id=23239&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23239&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23239&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23239&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23239&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23239&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23239&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23239&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23239&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23239&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23239&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23239&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23239&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23239&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23239&r=gnused
Thread (5 messages)
- bibifoc23 at yahoo dot fr