note 63811 added to function.func-get-args
| From: | bew at osu1 dot php dot net | Date: | Fri, 31 Mar 2006 15:55:18 +0000 |
| Subject: | note 63811 added to function.func-get-args | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107084@lists.php.net to get a copy of this message | ||
A more concise way of expressing my idea from the previous post (I'd forgotten about
array_slice()):
<?php
function func_get_default_args($a) {
$args = array_slice(func_get_args(), 1);
return array_merge($args, array_slice($a, sizeof($args)));
}
function foo($a = 1, $b = 2, $c = 3) {
print_r(func_get_default_args(func_get_args(), $a, $b, $c));
}
// prints: Array ( [0] => a [1] => b [2] => 3 )
foo('a', 'b');
?>
----
Server IP: 64.71.164.2
Probable Submitter: 68.59.225.167
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.func-get-args.php
Edit -- http://master.php.net/note/edit/63811
Del: integrated -- http://master.php.net/note/delete/63811/integrated
Del: useless -- http://master.php.net/note/delete/63811/useless
Del: bad code -- http://master.php.net/note/delete/63811/bad+code
Del: spam -- http://master.php.net/note/delete/63811/spam
Del: non-english -- http://master.php.net/note/delete/63811/non-english
Del: in docs -- http://master.php.net/note/delete/63811/in+docs
Del: other reasons-- http://master.php.net/note/delete/63811
Reject -- http://master.php.net/note/reject/63811
Search -- http://master.php.net/manage/user-notes.php