RE: [PHP] Associative arrays... help

From: Date: Fri, 01 Feb 2002 18:22:32 +0000
Subject: RE: [PHP] Associative arrays... help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83158@lists.php.net to get a copy of this message
You can have arrays of arrays of arrays of arrays if you like. But you must treat each array according to its type. I'm not sure what your function parse() is doing, but I assume it's going to build three list-type arrays. So when your looping through the associative array with a foreach() loop you'll access each list with a for() loop. // Loop through the associative array and echo list contents... foreach ($my_associative_array_of_list_arrays as $title => $list) { echo "<p>" . $title . ": <br>"; for ($i=0; $i<count($list); $i++) { echo $list[$i] . "<br>"; } } Unless you're going to access the list arrays by title (ie $applist[URL]) then there really isn't a point in using the associative array. Just put everything into a 2D list array and access them with a double for() loop. Hope this points you in the right direction. -- Kevin Stone Kevin@helpelf.com www.helpelf.com > -----Original Message----- > From: Sandeep Murphy [mailto:Sandeep.Murphy@oni.pt] > Sent: Friday, February 01, 2002 8:03 AM > To: php-general@lists.php.net > Subject: [PHP] Associative arrays... help > > Hi, > > sorry for repeating this...didnt change the sub..:) > Is there any way I can construct an associative array out of 3 other > arrays?? > > like for eg. > > function parse() { > > appid[]; > appnm[]; > url[]; > } > > I want to do something like this: > > function arr() { > > > $applist = array("APPID" =>$appid, > "APP NAME"=>$appnm, > "URL" =>$url); > > foreach($applist as $valor) > > echo $key . $valor; > } > > wud appreciate any help.. > > TIA, > sands > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#83158) next »