switch case statement

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

switch case statement

Post 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']  .'" />'; 
 
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: switch case statement

Post 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']  .'" />';
(#10850)
Post Reply