Browse - Programming Tips - What the best way to accept an array from a function?

Date: 2008may16
Language: php


Q.  What the best way to accept an array from a function?

A.  Use list(), like this:

function returnArray() { return array('one', 'two'); } function acceptArray() { # Note the use of list here. list($a, $b) = returnArray(); print "a=$a\n"; print "b=$b\n"; }