Re: adding a <br> tag in the middle of a loop

From: Date: Wed, 18 Oct 2000 21:28:30 +0000
Subject: Re: adding a <br> tag in the middle of a loop
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-20988@lists.php.net to get a copy of this message
On Wed, 18 Oct 2000, Rodney Davis wrote: > I am trying to output a given number of <input> tags > based on a variable with the following code: > > <?php > for ($i = 0; $i < $number; $i++) > { > echo "<input type=\"text\" name=\"variable[]\" > size=\"15\">"; > } > ?> > > But, if $number is a large number I get a huge string of > <input> tages. I would like to break these every three > iterations but I have no idea how to do this. Does > anyone know how to do this? > > Thanks in advance > > rodney <?php for ($i = 0; $i < $number; $i++) { echo "<input type=\"text\" name=\"variable[]\" size=\"15\">"; if (!($i % 3)) { echo "<br>\n"; } } ?> See the modulo operator: http://www.php.net/manual/language.operators.php -steve ........................................................... . Steve Edberg sbedberg@ucdavis.edu . . Computer Consultant University of California, Davis . . (530)754-9127 . ...........................................................

« previous php.general (#20988) next »