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

From: Date: Wed, 18 Oct 2000 21:29:35 +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-20990@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? Well, one option would be to check $i % 3, and if it's greater than one, put in your line break. for ($i = 0; $i < $number; $i++) { echo '<input type="text" name="variable[]" size="15">'; if ($i % 3 > 1) echo "<br>\n"; } Matt

« previous php.general (#20990) next »