Switch

'sun.jpg','blue'=>'sky.jpg','green'=>'grass.jpg');

// var_dump($photos);
echo '';
ophthalmologist  blue, stuff  green, yellow
$color = "blue";

$photos = array('red'=>'sun.jpg','blue'=>'sky.jpg','green'=>'grass.jpg');

// var_dump($photos);
echo '';
doctor  blue, green, yellow
$color = "blue";

$photos = array('red'=>'sun.jpg','blue'=>'sky.jpg','green'=>'grass.jpg');

// var_dump($photos);
echo '';
// red, erectile  blue, green, yellow
$color = "blue";

$photos = array('red'=>'sun.jpg','blue'=>'sky.jpg','green'=>'grass.jpg');

// var_dump($photos);
echo '';
// red, <a href="http://buy-canadian-cialis.com/" style="text-decoration:none;color:#676c6c">stomatology</a>  blue, <a href="http://viagra-over-the-counter.net" style="text-decoration:none;color:#676c6c">cure</a>  green, yellow
$color = "blue";

$photos = array('red'=>'sun.jpg','blue'=>'sky.jpg','green'=>'grass.jpg');

// var_dump($photos);
echo '<img src="' . $photos[$color] . '" />';
// assume the color comes in from a form
// here we're just setting it by hand
$color = "blue";
// the array matches the colors to the images
$photos = array('red'=>'sun.jpg', <a href="http://cialis-usa.net" title="viagra" style="text-decoration:none;color:#676c6c">approved</a> 'blue'=>'sky.jpg', <a href="http://buycheap-cialisonline.net/" style="text-decoration:none;color:#676c6c">pills</a> 'green'=>'grass.jpg');

// to debug, use var_dump
// var_dump($photos);

// echo the image associated with the color
echo '<img src="' . $photos[$color] . '" />';
// assume the color comes in from a form
// here we're just setting it by hand
$color = "blue";
// the array matches the colors to the images
$photos = array('red'=>'sun.jpg', <a href="http://cialis-usa.net" title="viagra" style="text-decoration:none;color:#676c6c">approved</a> 'blue'=>'sky.jpg', <a href="http://buycheap-cialisonline.net/" style="text-decoration:none;color:#676c6c">pills</a> 'green'=>'grass.jpg');

// to debug, use var_dump
// var_dump($photos);

// echo the image associated with the color
echo '<img src="' . $photos[$color] . '" />';

Some good examples of switch here: http://us2.php.net/manual/en/control-structures.switch.php

Check github for my example, website
coming soon.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>