how do I write echo img?

For general web development questions that are not specifically related to CSS HTML Validator. This includes (but is not limited to) general HTML, CSS, Accessibility, JavaScript, and SEO questions.
Post Reply
maichel
Rank 0 - Newcomer
Posts: 6
Joined: Mon Oct 05, 2015 8:13 am

how do I write echo img?

Post 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);
User avatar
Albert Wiersch
Site Admin
Posts: 3783
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: how do I write echo img?

Post 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.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
Post Reply