RE: [PHP] array/iteration issue!!

From: Date: Fri, 28 Nov 2008 04:49:12 +0000
Subject: RE: [PHP] array/iteration issue!!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-283884@lists.php.net to get a copy of this message
both ways work...!!! this is a really simple/quick issue to populate some test db tbls.. i've only played with multi php arrays (sp??) in passing... and my days of being a serious eng/software guy are long over!! although.. with this economy! thanks -----Original Message----- From: Robert Cummings [mailto:robert@interjinn.com] Sent: Thursday, November 27, 2008 8:40 PM To: Micah Gersten Cc: bruce; 'PHP General list' Subject: Re: [PHP] array/iteration issue!! On Thu, 2008-11-27 at 22:22 -0600, Micah Gersten wrote: > > This is actually a much smaller data structure. > > $colleges = array > ( > 'Blah Blah University' => > array > ( > 'physics' => array > ( > 'sss', > 'sffgg', > ), > 'english' => array > ( > 'sss', > 'sffgg', > ) > ), > 'Glah Gleh University' => > array > ( > 'physics' => array > ( > 'sss', > 'sffgg', > ), > 'english' => array > ( > 'sss', > 'sffgg', > ), > ) > ); > > > foreach( $colleges as $collegeName => $depts ) > { > foreach( $depts as $deptName => $classes) > { > foreach( $classes as $className ) > { > echo "$collegeName, $deptName, $className\n"; > } > } > } Yes, I thought of that one too, but it's less flexible. What if you need to add other fields to the college, or department. Then you'd need to redo the whole structure to something more similar to what I did. Since bruce was having issues, I gave him a flexible format that could handle other fields if they arose. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#283884) next »