Function with list()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pineriver
Forum Commoner
Posts: 50
Joined: Fri Aug 15, 2003 5:24 pm

Function with list()

Post by Pineriver »

Hello,
How would I do, or is it possible to go

Code: Select all

function foo($in){
return list($aval,$bval,$cval,$dval)=explode("-",  $in  );
}

foo("a-b-c-d");
then it would return the vars of list(), avar bvar cvar dvar.

Would this be possible to return all of these variables from a function?
thanks
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

you cannot return "variables" only values...
my suggested approach is returning an array with keys and values, which can if liked be "extracted" or what it's called, making all the keys become "variables".
Post Reply