note 50008 added to function.func-get-args

From: Date: Tue, 15 Feb 2005 08:47:10 +0000
Subject: note 50008 added to function.func-get-args
Groups: php.notes 
Request: Send a blank email to php-notes+get-85055@lists.php.net to get a copy of this message
# Another attempt at named args (perl-inspired): # list_to_assoc('key', 'value', 'key', 'value', ...) => # pairs[] function list_to_assoc() { $list = func_get_args(); $assoc = array(); while ($list and count($list) > 1) { $assoc[array_shift($list)] = array_shift($list); } if ($list) { $assoc[] = $list[0]; } return $assoc; } # Usage: function example($required) { $args = func_get_args(); array_shift($args); # drop 'required' $rest = list_to_assoc($args); echo "$required\n" . $rest['comment']; } example("This is required...", 'comment', 'this is not.'); # this is like 'comment' => 'this is not' ---- Manual Page -- http://www.php.net/manual/en/function.func-get-args.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50008 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50008&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50008&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50008&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50008&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50008&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50008&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85055) next »