How to get the name of what coin was tossed to show instead of a number

I made a flip a coin game. It consists of three rows. I want the flip number what the flip was and the coin. I have all except the name of the flip like (heads,tails) I am only getting the number that I set for the flip. How do I get the flip to say the word ‘heads’ for 0 or ‘tails’ for 1 instead of just 0 or 1. I tried to do it in an echo I still received the number.this is the code I have

[code]

Coin

Coin

Coin

<?php echo ""; echo ""; echo "";

echo “

”;
echo “”;
echo “”;
for($i=0; $i<20; $i++){
//0 is heads
//1 is tails
$result = rand(0, 1);
$count = $i+1;
echo “”;
echo “”;
echo “”;
if($result == 0){
echo "<td><img src=\"heads.jpg\" alt=\"heads\"></td>";

} else {
echo “

”;
}
echo “”;
}
echo “”;
echo “
”. $count . “” . $result . “ <img src=“tails.jpg” alt=“tails”>
”;
?>

php [/code]

You will have to look the syntax up, that is why I’m posting the answer instead of leading you to it.

This line:
[php]echo “

” . $result . “”;[/php]

Changes to:
[php]echo ‘

’ . ($result == 0 ? ‘Heads’ : ‘Tails’) . ‘’;[/php]

I originally posted an answer and removed when I found it posted on a few forums, and it seems they are looking for a spoon fed answers.

If you notice this,
[php] if($result == 0){

 echo "<td><img src=\"heads.jpg\" alt=\"heads\"></td>";

} else {
echo “

<img src=“tails.jpg” alt=“tails”>”;
}[/php]

They should know how to do what they want. They just don’t want to do so.

Ha, I didn’t even look that far down. :o

Oh, well, I was bored anyhow!

I didnt want the answer I just needed a hint. I posted on another forum and I didnt even go back to see the hints because I still have been trying to figure this out on my own. I am new to php and unfamiliar with the syntax. Maybe I should showed you what I tried so you wouldnt think I just wanted the answer. Thi is what tried

heads

It was clearly wrong but Ill keep trying.

does the correct image show for you?

Sponsor our Newsletter | Privacy Policy | Terms of Service