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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.