note 53789 added to function.compact

From: Date: Mon, 13 Jun 2005 15:43:01 +0000
Subject: note 53789 added to function.compact
Groups: php.notes 
Request: Send a blank email to php-notes+get-90357@lists.php.net to get a copy of this message
The compact function doesn't work inside the classes or functions. I think its escope is local... Above it is a code to help about it. Comments & Suggestions are welcome. PS: Sorry for my poor english... <?php function x_compact() { if(func_num_args()==0) { return false; } $m=array(); function attach($val) { global $m; if((!is_numeric($val)) && array_key_exists($val,$GLOBALS)) { $m[$val]=$GLOBALS[$val];} } function sub($par) { global $m; if(is_array($par)) { foreach($par as $cel) { if(is_array($cel)) { sub($cel); } else { attach($cel); } } } else { attach($par); } return $m; } for($i=0;$i<func_num_args();$i++) { $arg=func_get_arg($i); sub($arg); } return sub($arg); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.compact.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53789 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53789&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53789&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53789&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53789&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53789&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53789&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90357) next »