Dave's Brain

Browse - programming tips - php receive 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";
}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, 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.
Advertisements: