Re: Array

From: Date: Wed, 22 Aug 2001 01:58:00 +0000
Subject: Re: Array
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-8986@lists.php.net to get a copy of this message
To have the items auto-numberd so as to skip blank entries, use: for ($i = 1; $i<6; $i++) { print "<input type=\"text\" name=\"test[]\">\n"; } then if on items 1,2 and 5 are filled in, you will have a array with just 3 elements in it. "Mike Flynn" <mike@mikeflynn.net> wrote in message news:5.1.0.14.2.20010821104612.00a6f770@mail.mikeflynn.net... > Alternately, though I think the array solution is probably the most > durable, you could also do it as such: > > for ($i = 1; $i<6; $i++) { > print "<input type=\"text\" name=\"test$i\">\n"; > } > > and then retrieve them as $test1 thru $test6, or if you want to use a loop > like this: > for ($i = 1; $i < 6; $i++) { > $thevariable = "test$i"; > $thevalue = $$thevariable; > } > > At 03:36 PM 8/21/2001 +0200, Darvin Andrioli wrote: > >Change your code in: > > > > <? > > for ($i=1; $i<6; $i++) { > ><input type="text" name="test[$i]"> > >} > >?> > > > >You will obtain an array, named test, with 5 elements. > > > >Bye > > > >Darvin > > > > > -----Messaggio originale----- > > > Da: Sichta Daniel [mailto:Daniel.Sichta@swh.sk] > > > Inviato: martedi 21 agosto 2001 15.15 > > > A: php-windows@lists.php.net > > > Oggetto: [PHP-WIN] Array > > > > > > > > > Hi there !! > > > cfg: php4.0.4pl1, w2k, apache 1.3.20 > > > Situation: > > > <? > > > for ($i=1; $i<6; $i++) { > > > <input type="text" name="test"> > > > } > > > ?> > > > This is all in one form. How can I get all five values of test from this > > > kind of code ? > > > > > > DAN > > > > > > >-- > >PHP Windows Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > >For additional commands, e-mail: php-windows-help@lists.php.net > >To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > -=- Mike Flynn - Burlington, VT -=- > mike@mikeflynn.net http://www.mikeflynn.net/ * Give blood * > the classic example of liberal, consensus, win-win, > Clintonesque, spin doctor, sell-out, cultural appropriation, > commodification of dissent type event in the world today > (-BBB) > >

« previous php.windows (#8986) next »