Jump to content

Two variables in on field.


11Tami

Recommended Posts

Hello, how can I include two PHP variables in an image src, depending on which variable I will be using at the time?

For example:

 

 

 

 

 

 

 

 

 

 

 

 

<?php
$image[1] = "http://store.officeworld.com/ProductImages/united/standard/MOW36113_1_1.JPG";
$image[2] = "https://store.officeworld.com/productimages/united/thumbnails/HAM122549_1_1_100.jpg";
$image[4] = "https://store.officeworld.com/productimages/united/thumbnails/A0001856.JPG";
$image[5] = "https://store.officeworld.com/productimages/united/thumbnails/HEWQ1396A_1_1_100.jpg";
$get1 = rand(1,2);
$get2 =  rand(3,4);
echo "<img src='$image[$get1($get2)]' >"; 
?>

 

This following part from the above script I need help with: echo "<img src='$image[$get1($get2)]' >";

 

Sometimes I will only be using $get1 from the array, and other times I will only be using $get2 from the array, depending on what a database inserts into the image source. How can I have the src hold both $get1 and $get2 variables at the same time? The way I have it above says it cannot hold both. Please let me know, thank you very much.

Link to comment
https://forums.phpfreaks.com/topic/86027-two-variables-in-on-field/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.