how do I write echo img?

Discussion about any web related scripting languages like JavaScript, ASP, and PHP.
Post Reply
maichel
Rank 0 - Newcomer
Rank 0 - Newcomer
Posts: 6
Joined: Mon Oct 05, 2015 8:13 am

how do I write echo img?

Post by maichel » Wed Oct 21, 2015 6:15 am

Hello,

I have a php script. The meaning is when you see three of the same images you see a echo you win.
But how can I write the echo img of the three variables?

can someone help me?

thanks in advance.

my code is:

Code: Select all

function jackpot(){

$a=array("1.jpg", "2.jpg", "3.jpg");


$cur_rndNumA=mt_rand(0,count($a)-1);
$cur_rndNumB=mt_rand(0,count($a)-1);
$cur_rndNumC=mt_rand(0,count($a)-1);

[b]echo "<img src=\"$a[$cur_rndNumA]\" "\$a[$cur_rndNumB]\" "\$a[$cur_rndNumC]\" ">" "; //HOW WRITE I THIS?[/b]


if($a[$cur_rndNumA] == "1.jpg" && $a[$cur_rndNumB] == "1.jpg" && $a[$cur_rndNumC] == "1.jpg" ){
echo "you win";
}

if($a[$cur_rndNumA] == "2.jpg" && $a[$cur_rndNumB] == "2.jpg" && $a[$cur_rndNumC] == "2.jpg" ){
echo "you win";
}

if($a[$cur_rndNumA] == "3.jpg" && $a[$cur_rndNumB] == "3.jpg" && $a[$cur_rndNumC] == "3.jpg" ){
echo "you win";
}

}

jackpot($a);

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3347
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: how do I write echo img?

Post by Albert Wiersch » Wed Oct 21, 2015 7:12 pm

I would use something like this:

Code: Select all

echo '<img src="'.$a[$cur_rndNumA].'">';
And similar echo lines to echo "img" elements for the other images.
Image
Albert Wiersch

Post Reply