Posted by brant : 2008-05-24 at 4:44 pm
The trick to return more than one value in a function can be applied to any programming language, but this example is in PHP. Functions are designed to return one value, but there really is no limit to have many values that can be returned. So lets take a look at the code:
/* Example code */
list($var1, $var2) = returnYankees();
print "$var1 $var2";
function returnYankees(){
$a = "go";
$b = "yankees";
return array($a,$b);
}
The code is self explanitory and I don't think I need to go into too much depth. I will say that the $a or $b values that are returned can also be arrays as well. Now you can make one complex function rather than multiple functions!
Similar Blogs:
Firefox Had Its Chance, It's Time For Google Chrome
Automate Wordpress Posting
MySQL, How To SUM Time Correctly
Get Server Load Averages In PHP
blog comments powered by Disqus
OLD Comments (1)
ecommerce website develop - 2009-11-17 at 07:53:26
You can do it like that or return an array from function.
Blog Posts
- The Sad Truth About SEOBook
- Firefox Had Its Chance, It's Time For Google Chrome
- Cancel Your FreeCreditReport.com Account Without Calling
- Automate Wordpress Posting
- MySQL, How To SUM Time Correctly
« Previous
Recent Popular Posts
Most Commented Blog Posts
- Nintendo Wii Sucks (228)
- Microsoft Windows Search Indexer Stopped Working (32)
- GMX Mail Review (31)
- Windows Vista And Windows 7 0x80070017 Error (16)
- How To Block Ad-Brite Transition Ads (14)
