Author Topic: Display an image by value  (Read 550 times)

0 Members and 1 Guest are viewing this topic.

Offline xwishmasterxTopic starter

  • Enthusiast
  • Posts: 116
    • View Profile
Display an image by value
« on: March 16, 2010, 07:21:34 AM »
Hello

I am not really good at php or programming and I need a llittle help:

I need a value to be "converted" to an image;

so if the value is "eg.3" it should show eg. "img3.gif"

(the images are stored in a folder)

The value is displayed  from:

Code: [Select]
{case value="text"}
    {$extraField.value}

So far it will show the value, but how can I make it display my image instead?

Offline The Little Guy

  • Freak!
  • Posts: 6,103
  • Gender: Male
  • Jinkies!
    • View Profile
    • PHPSnips
Re: Display an image by value
« Reply #1 on: March 19, 2010, 01:14:01 AM »
you could do this:

$str 'eg.3';
list(
$eg$img) = explode('.'$str);
echo 
$eg.' <img src="/images/img'.$img.'.gif" />';
phpLive - A powerful library that implements many common tasks to make php programming faster. Supports extensions and plugins. Current version: 1.0.0-Alpha
JPG to ASCII Converter | Advanced Image CAPTCHA | Simple User Login | Check If User Is Logged In
http://dreamhost.com (promo code: 8RN4)
$30 off 1 year of hosting
$40 off 2 years of hosting