Dave's Brain

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"; }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.