Page 1 of 1

switch case statement

Posted: Sun Mar 09, 2008 8:54 am
by kkonline
In the below switch case statement i want to check if value of $mime is "image/" and not be very specific to image/jpeg, It can be gif png or anything i am just concerned about "image/" part in the mime

The way it is stored in database is image/jpeg image/gif etc . What should i do?

Code: Select all

switch ($mime) {
case "image/jpeg":
    echo '<img src="'.$row['link'].'" border="0" height="50" width="50" alt="' . $row['title']  .'" />'; 
 

Re: switch case statement

Posted: Sun Mar 09, 2008 1:42 pm
by Christopher
How about:

Code: Select all

list($type, $format) = explode('/', $mime);
switch ($type) {
case "image":
    echo '<img src="'.$row['link'].'" border="0" height="50" width="50" alt="' . $row['title']  .'" />';