Forum Moderators: coopster

Message Too Old, No Replies

Displaying two different images

depending on value of a text file

         

lindajames

12:53 am on Jun 18, 2003 (gmt 0)

10+ Year Member



Hi there,

I have a php file that has an <img> tag but what i want to do is basically make two different images load depending on the value of a text file. For example if image.txt has data in it it should display image1.jpg or if image.txt is empty then it should display image2.jpg.

Can anyone tell me how this can be done in PHP?

Cheers
Linda

jatar_k

1:45 am on Jun 18, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



$imgtext = join("",file("image.txt"));
if (empty($imgtext)) {
echo "<img src\"image2.jpg\">";
} else {
echo "<img src\"image1.jpg\">";
}

should work, might take some tweaking, php.net can help you with what those functions do. Search the function list for the function names.