Version 25 of PHP

Updated 2005-06-20 18:44:16

<html> <head> <title>Counting from x to y</title> </head> <body bgcolor="white">

<?php function print_sequence ($start, $stop, $increment) { if ($start > $stop) { return(FALSE); } elseif ($increment <= 0) { return(FALSE); } else { for ($i = $start; $i < $stop; $i = $i + $increment) { print "$i "; } } return(TRUE); } ?>

<h1>Counting from x to y</h1> <p> Counting from 1 to 10 by 1: <?php print_sequence(1, 10, 1)?> </p> <p> Counting from 2 to 20 by 2: <?php print_sequence(2, 20, 2)?> </p> </body> </html>