Bug #52336 [Opn->Bgs]: You can't use multidimensional arrays in functions which support arrays.

From: Date: Tue, 21 Sep 2010 15:58:11 +0000
Subject: Bug #52336 [Opn->Bgs]: You can't use multidimensional arrays in functions which support arrays.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5102@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52336&edit=1 ID: 52336 Updated by: markskilbeck@php.net Reported by: j dot pruehsing at web dot de Summary: You can't use multidimensional arrays in functions which support arrays. -Status: Open +Status: Bogus Type: Bug Package: Documentation problem Operating System: Windows + Linux PHP Version: Irrelevant Block user comment: N New Comment: This isn't a bug. The documentation says you can pass an array of needles and an array of replacements. It's just common-sense that these needles/replacements would be scalar types (not an array). Previous Comments: ------------------------------------------------------------------------ [2010-07-14 13:53:10] j dot pruehsing at web dot de Description: ------------ The documentation for functions like str_replace says, that you can use an array as subject. Multidimensional arrays are not excluded, but if you use them nothing happens. This bug is reproducable with ALL functions which should support the use of array. If this is wanted behaviour you should edit the documentation. Test script: --------------- $testarray = array(array('bla', 'blub'),array('blub', 'bla')); $testarray = str_replace('bla', 'blub', $testarray); //doesn't work print_r($testarray); echo('<br>'); for($i=0; $i<count($testarray); $i++) { $testarray[$i] = str_replace('bla', 'blub', $testarray[$i]); //works } print_r($testarray); Expected result: ---------------- -only array output of 'blub' Actual result: -------------- Array ( [0] => Array ( [0] => bla [1] => blub ) [1] => Array ( [0] => blub [1] => bla ) ) Array ( [0] => Array ( [0] => blub [1] => blub ) [1] => Array ( [0] => blub [1] => blub ) ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52336&edit=1

« previous php.doc.bugs (#5102) next »