List Info

Thread: note 63811 added to function.func-get-args




note 63811 added to function.func-get-args
user name
2006-03-31 15:55:18
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.p
hp.net/note/edit/63811
Del: integrated  -- ht
tp://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://m
aster.php.net/note/delete/63811/spam
Del: non-english -- h
ttp://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://ma
ster.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )