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:
6 Tips For Parsing HTML
Awstats Will Lag Your Box
PHP: How To Fix "Class 'ZipArchive' Not Found"
Blog Posts
- The Olympics Suck
- So How Smart Is GoogleBot And Forms?
- 6 Tips For Parsing HTML
- MLB Run Differential Breakdowns
- PHP Function To Return Mutiple Values
« Previous
Search
NJ Beach Checker
| August 2008 | ||||||
| S | M | T | W | T | F | S |
| 27 | 28 | 29 | 30 | 31 | 1 | 2 |
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 | 1 | 2 | 3 | 4 | 5 | 6 |
| « last | next » |
| beach days: | 52/80 (65.00%) |
| perfect beach days: | 7/52 (13.46%) |
| bad beach days: | 28/80 (35.00%) |
| best beach streak: | 9 days |
| worst beach streak: | 6 days |
| avg temp: | 82.71° |
| avg wind: | 12.88 mph |
| avg water temp: | 69.53° |
One Year Ago
Day: MondayType: very_good
Temp: 81°
Wind: 4 mph
Water: 74°
Wave Height: 2 ft.
