php - Display counting variable in for -


so i'm trying learn php..

    <form action="momo.php" method="post">          <label for="number1">repeat:</label>         <input type="text" name="number1">  <br>         <label for="text1">text:</label>         <input type="text" name="text1"> <br>          <input type="submit" name="send">      </form> 
if(isset($_post['number1'])) {      $number1= $_post['number1'];     $text1= $_post['text1'];          if(is_numeric($number1)) {              echo "numerical!<br><br>";              for($i=0;$i<$number1;$i++) {             echo $text1;             }          }             else {             echo "not numerical!";                       } } 

..and i've managed make work! cannot make count each result though, i've tried count() i'm not sure how use it, , can find how use arrays.

if enter this:

  • repeat: 3
  • text: hi!

it'll this:

hi! hi! hi! 

though want this:

1 hi! 2 hi! 3 hi! 

try this:

for($i=0;$i<$number1;$i++) {     echo $i+1.' '.$text1; } 

or

for($i=1;$i<=$number1;$i++) {     echo $i.' '.$text1; } 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -