hey all,
I am new to PHP and have been working through a tutorial I found to create a hangman script but I am getting the error
Warning: Invalid argument supplied for foreach() in /- on line 29
here is the code I have
<?php
$words = array (
"giants",
"triangle",
"particle",
"birdhouse",
"minimum",
"flood"
);
$letters = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
'p','q','r','s','t','u','v','w','x','y','z');
$right = array_fill_keys($letters, '.');
$wrong = array();
if (stristr($word, $guess)) {
$show = '';
$right[$guess] = $guess;
$wordletters = str_split($word);
foreach ($wordletters as $letter) {
$show .= $right[$letter];
}
} else {
$show = '';
$wrong[$guess] = $guess;
if (count($wrong) == 6) {
$show = $word;
} else {
foreach ($wordletters as $letter) {
$show .= $right[$letter];
}
}
}
?>