PHP counting the letters in a word (HANGMAN) <p>I am trying to make a hangman game. I have a few words in an array and when one of them is picked I want to count how many letters are in that word so that it can then make that amount of spaces or dashes. Also I need an efficient way to put each letter of the word onto the screen. Each letter is to be invisible, so then when the letter is guessed it will be made visible.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt; Hangman &lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt; Hangman &lt;h1&gt; &lt;?php session_start(); $maxAttempts = 6; $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'); ?&gt; &lt;form name="lettersubmit" method="post" action="Hangman.php" &gt; &lt;input name="letterguess" type= "text" value=""&gt; &lt;input name="submit" type="submit" value="Guess a Letter!"&gt;&lt;br&gt; &lt;p&gt; Guesses Remaining &lt;p&gt; &lt;input name="triesRemaining" type="text" value="&lt;?php print("$maxAttempts"); ?&gt;"&gt; &lt;/form&gt; &lt;?php $letterguess = $_POST["letterguess"]; if($letterguess= $word){ echo ("correct"); } if(!isset($_POST["submit"])){ $words = array ( "giants", "triangle", "particle", "birdhouse", "minimum", "flood", $word = $words[array_rand($words)]; ); } if(isset($_POST["submit"])){ $maxAttempts--; } $word = $words[array_rand($words)]; echo $words[array_rand($words)]; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>