Dynamic image loading?

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
bhtp
Forum Newbie
Posts: 2
Joined: Fri Aug 22, 2008 6:01 pm

Dynamic image loading?

Post by bhtp »

Hi, Im using a geolocation database which outputs the countries name and a two letter country code. I would like to load the according country flag the country flags correspond to the two letters. Like Canada is CA and its image is ca.png. I would like to dynamically load the image. The two letters are a variable. Can i do this in php?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Dynamic image loading?

Post by Christopher »

Code: Select all

<img src="images/<?php echo $country; ?>.png"/>
Or:

Code: Select all

echo "<img src=\"images/$country.png\"/>";
(#10850)
bhtp
Forum Newbie
Posts: 2
Joined: Fri Aug 22, 2008 6:01 pm

Re: Dynamic image loading?

Post by bhtp »

thankyou
Post Reply