...

View Full Version : simple hangman game. How do i check to see if the letter is in the array [0]



lordofun
06-10-2010, 10:20 AM
this is as far as i could get with the checking part. this isn't homework or anything just fun.

$guess = ($_POST['guess']);

$wds = array(rat, cat, mouse, meow, tree, house, goat, hat, grass, people, spider);

if ($turn == 11 Xor $word == "correct"){
shuffle ($wds);
}
$check = array($spwds);

thank you in advance

DJCMBear
06-10-2010, 11:32 AM
use the in_array(); function

lordofun
06-10-2010, 11:35 AM
but wont they have to use a whole word rather than one letter

DJCMBear
06-10-2010, 11:52 AM
are you trying to search for one letter in a word of an item of the array or search in the array for a word for them to enter?

Would you be able to post the whole code as the code in post #1 $spwds and that var hasn't been set in the code.

lordofun
06-15-2010, 01:27 PM
im trying to search for one letter of an item in the array.

MattF
06-15-2010, 01:35 PM
$find = 'something';

foreach ($wds as $key => $val)
{
if (strpos($val, $find) !== false)
{
[code for a match found here]
}
}

lordofun
06-15-2010, 01:36 PM
thank you.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum