note 18310 deleted from language.types.array by curt

From: Date: Tue, 06 Jul 2004 02:11:11 +0000
Subject: note 18310 deleted from language.types.array by curt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72642@lists.php.net to get a copy of this message
Note Submitter: andrew@majiclab.ab.ca ---- In addition to some of the notes already given, I have found the following very useful! In an HTML form, you can use arrays: <input type=text name=MyArray[]> However, a more useful application would be like this: <input type=text name=MyArray[Settings][Name]> <input type=text name=MyArray[Settings][Age]> <input type=text name=MyArray[Prefrences][Color]> And so on. PHP will parse it all properly for you. You can have as many dimensions to the array as you would like, I suppose. Another good reason that this works well: foreach( $MyArray[ 'Settings' ] as $Param => $Value ) @eval( "\$this->$Param = \"$Value\";" ); That will go through all the parameters for settings and assign to the $this object. This is useful if you are using sessions, and you have an object defined as a session variable, like user. Then you can just run $User->LoadFormParams() and run the loop above, and your settings are all put into the object!!! Hope this gives some of you some crazy ideas!! -Andrew "Percy" Hanna

« previous php.notes (#72642) next »