My PHP Sandwich
What if I could control my world the same way that I control a website? Even if you don’t program I think you can understand this:
<?php
// sandwich options
$meat = array('Ham', 'Turkey', 'Balogna', 'Tuna');
$bread = array('Whole Wheat', 'White', 'Potatoe');
$spread = array('Mayo', 'Mustard', 'French Dressing');
// get random sandwich ingredients
$randomMeat = $meat[rand(0,count($meat)-1)];
$randomBread = $bread[rand(0,count($bread)-1)];
$randomSpread = $spread[rand(0,count($spread)-1)];
// make a sandwich
makeSandwich($randomMeat, $randomBread, $randomSpread);
/**
* makes a sandwich out of the given ingredients
*
* @author Tim Golen (tg)
* 04/08/2008 - (tg) created function
* @param string $meat
* @param string $bread
* @param string $spread
* @return array
*/
function makeSandwich($meat, $bread, $spread){
$mySandwich = array(
$bread,
$spread,
$meat,
$bread);
return $mySandwich;
}
?>
1 Comment
You should ‘salt’ your random number generators!
Groan, that was a bad, bad pun!