RE: array/iteration issue!!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx]
Sent: Thursday, November 27, 2008 8:40 PM
To: Micah Gersten
Cc: bruce; 'PHP General list'
Subject: Re:  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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux