Page 1 of 1

how do I write echo img?

Posted: Wed Oct 21, 2015 6:15 am
by maichel
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);

Re: how do I write echo img?

Posted: Wed Oct 21, 2015 7:12 pm
by Albert Wiersch
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.