php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34335 nested array_walk calls fail
Submitted: 2005-09-01 19:56 UTC Modified: 2005-09-01 23:41 UTC
From: gubespam at _NOSPAM_gmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.0.4 OS: Apache/Unix
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gubespam at _NOSPAM_gmail dot com
New email:
PHP Version: OS:

 

 [2005-09-01 19:56 UTC] gubespam at _NOSPAM_gmail dot com
Description:
------------
When making nested calls to array_walk, it does not behave as it should. Supposedly this has been fixed, but it doesn't appear so.  Please refer to the now-closed bug report #33286.  To see it working on my server running 5.0.4, go to:

http://web.ics.purdue.edu/~varsity/array_walk.php


Reproduce code:
---------------
<?php
function test_subfunc(&$item1, $key, &$prefix)
{
   echo "&nbsp;&nbsp;test_subfunc<br/>";
}

function test_func($item2, $key)
{
   echo "test_func<br/>";

   $arr = array(1, 2, 3, 4);
   array_walk($arr, 'test_subfunc', 'extra_arg');
}

$x = array(5,6,7);
array_walk($x, 'test_func');
?>

Expected result:
----------------
test_func
  test_subfunc
  test_subfunc
  test_subfunc
  test_subfunc
test_func
  test_subfunc
  test_subfunc
  test_subfunc
  test_subfunc
test_func
  test_subfunc
  test_subfunc
  test_subfunc
  test_subfunc

Actual result:
--------------
test_func
  test_subfunc
  test_subfunc
  test_subfunc
  test_subfunc

Warning: Missing argument 3 for test_subfunc() in array_walk.php on line 2
  test_subfunc

Warning: Missing argument 3 for test_subfunc() in array_walk.php on line 2
  test_subfunc

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-01 23:41 UTC] sniper@php.net
It's fixed in CVS. Did you really expect that we get it fixed in your installed 5.0.4 with some magic or what?

 [2005-09-01 23:41 UTC] sniper@php.net
And with CVS I mean PHP 5.1-dev..

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 10 19:01:34 2025 UTC