Re: How to construct variable names ?!

From: Date: Sun, 26 Nov 2000 17:02:49 +0000
Subject: Re: How to construct variable names ?!
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-27266@lists.php.net to get a copy of this message
On Sun, Nov 26, 2000 at 10:54:49AM +0100, Juergen Hall wrote: > hi Jason, > > i want to do it, because i'm going to echo > a varying amount of input fields for textentries > later in my script. > The purpose of the derived variables is for > the name attributes in those input fields. aha. Here's a tip that may or may not make your life easier. Did you know that you can do both: <input type=whatever name="foo[]" value=whatever> AND <input type=whatever name="foo[$i]" value=whatever> where $i is whatever you want it to be. numbers, strings, etc. the first example auto-assigns the array indices in order starting from 0 (I think) every time you use foo[]. The second example uses your own array indices. And you CAN have non-sequential indices. That way, your script can deal exclusively with the foo array and never have to go back and forth between foo[x] and foox. That little feature has made my life much easier on several occasions.

« previous php.general (#27266) next »