php-general | 2005051
Date: 05/11/05
- Next message: AC: "Re: [PHP] str_replace on words?"
- Previous message: Murray @ PlanetThoughtful: "RE: [PHP] expand array into function arguments?"
- Maybe in reply to: Christopher J. Bottaro: "[PHP] expand array into function arguments?"
- Next in thread: Richard Lynch: "Re: [PHP] expand array into function arguments?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
There's probably some clever answer to this like "Just do myFunc($myList) and it'll automatically parse out the arguments".. because PHP does clever things like that sometimes.
But if anything, you can do something like this:
$myList = array(1, "arg", 5);
myFunc($myList);
function myFunc($argarr) {
list($arg1, $arg2, $arg3) = $argarr;
#do something
}
You might try this and see if it works (again, PHP is clever like this sometimes):
$myList = array(1, "arg", 5);
myFunc($myList);
function myFunc($arg1, $arg2, $arg3) {
list($arg1, $arg2, $arg3) = $argarr;
#do something
}
Maybe it automatically splits the array for you.
-TG
= = = Original message = = =
You can do this in Python:
<code>
def myFunc(arg1, arg2, arg):
#do something
myList = [1, "arg", 5]
myFunc(*myList) # calls myFunc(1, "arg", 2)
<code>
Can that be done in PHP, and if so, how?
Thanks for the help.
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: AC: "Re: [PHP] str_replace on words?"
- Previous message: Murray @ PlanetThoughtful: "RE: [PHP] expand array into function arguments?"
- Maybe in reply to: Christopher J. Bottaro: "[PHP] expand array into function arguments?"
- Next in thread: Richard Lynch: "Re: [PHP] expand array into function arguments?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

