php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32984 problem with array_walk()
Submitted: 2005-05-09 13:07 UTC Modified: 2005-05-17 01:00 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: arne dot binder at blue-com dot de Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: 5.0.4 OS: Windows NT4
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-05-09 13:07 UTC] arne dot binder at blue-com dot de
Description:
------------
The problem is the location of the declaration of the used callback-function in array_walk(). If this declaration is inside a switch-block (but if-blocks work!), array_walk() crashes php.

The following sample-code illustrates the problem. If the function declaration is moved out of the switch-block, everything works fine.

Reproduce code:
---------------
<?
$cond = 1;

switch ($cond) {
case 1:
	$arr = array('Line' => ' 1');

	print_r($arr);

	function trim_it(&$item, $key) { $item=trim($item); }

	array_walk($arr, 'trim_it');

	print_r($arr);
	break;
}
?>

Expected result:
----------------
Array
(
    [Line] =>  1
)
Array
(
    [Line] => 1
)


Actual result:
--------------
Ask Dr. Watson for NT4 ;-)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-10 00:57 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.0-win32-latest.zip

Works fine for me.


 [2005-05-17 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 26 11:01:30 2024 UTC