I have a secret word. People need to guess the secret word by entering single letters. When they start it will have **** for the word. When they guess a letter, an asterick shoud be replaced with the correctly guessed letter.
I cant get the charachter to replace in the correct position or keep the astericks visible. Also there should be hidden field for for the secret word, but when i make it hiddden I don't know how to output the replaced string. Any help would be great.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
  <link rel="stylesheet" href="teams.css" type="text/css" />
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  $word = 'rocky';
  $secret = '*****';

     echo "<p>Enter a lower case letter and click the Submit button to guess the word</P>";

     if (isset($_POST['Submit'])) {
        $letter = $_POST['letter'];
      $secret = $_POST['secret'];
       for ($i=0; $i<strlen($word); $i++) {
            if($word[$i] == $letter){
              $pos =  strpos($word, $letter);
               $secret = substr_replace($secret, $letter, $pos);



 <form name="Word Guess" action="Guess19373.php" method="POST">
 <p>Enter a letter: <input type="text" name="letter" value="<?php echo $letter; ?>" /></p>
 <p>The secret word is: <input type="text" name="secret" value="<?php echo $secret; ?>"  /></p>
 <p><input type="submit" name="Submit" value="Give it a guess" /></p>


I would do something like

        $arrayName = 'guessword';

        $guess = 'e';

        for ($i=0; $i < strlen($arrayName); $i++) 
            if ($guess == $arrayName[$i])
                echo $arrayName[$i];
                echo '*';