|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-05-10 00:57 UTC] sniper@php.net
[2005-05-17 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 09:00:01 2025 UTC |
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 ;-)