|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52336 You can't use multidimensional arrays in functions which support arrays.
Submitted: 2010-07-14 13:53 UTC Modified: 2010-09-21 17:58 UTC
From: j dot pruehsing at web dot de Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Windows + Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: j dot pruehsing at web dot de
New email:
PHP Version: OS:


 [2010-07-14 13:53 UTC] j dot pruehsing at web dot de
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

for($i=0; $i<count($testarray); $i++)
  $testarray[$i] = str_replace('bla', 'blub', $testarray[$i]); //works

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 ) ) 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-21 17:58 UTC]
-Status: Open +Status: Bogus
 [2010-09-21 17:58 UTC]
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).
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jul 27 00:01:25 2021 UTC