note 86498 deleted from function.array-walk by felipe

From: Date: Wed, 22 Oct 2008 12:45:16 +0000
Subject: note 86498 deleted from function.array-walk by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145578@lists.php.net to get a copy of this message
Note Submitter: diyism ---- Although the manual warned you not to unset element, but sometimes thus is very useful and work as charm: $arrChnOut=array(0=>array('ID' => '13', 'ChannelName' => 'Computers' ), 1=>array('ID' => '17', 'ChannelName' => 'Computers' ), 2=>array('ID' => '18', 'ChannelName' => 'Computers' ), ); array_walk($arrChnOut, create_function('&$v, $k, $arr_rtn', 'if ($k{0}!="_"){$arr_rtn["_".$v[\'ID\']]=$v;unset($arr_rtn[$k]);}'), &$arrChnOut); var_export($arrChnOut);

« previous php.notes (#145578) next »