...

View Full Version : 3-D array loop, Loop based on 3rd key



mathceleb
06-01-2011, 09:32 PM
This is another question that arose from the task from this thread:

http://www.codingforums.com/showthread.php?t=227815

Now, I need to loop through any school that matches the name, for any city and any state.


$school="University of Illinois";
foreach($codes[][][$school] as $school_key=>$school_value){

}

I tried the above with no success. I need to have the loop move to the 3rd key automatically and just grab any school with that name.

I'm trying to avoid looping through each city, then each state, then each school if possible.

array_keys perhaps?

Inigoesdr
06-01-2011, 09:47 PM
If you don't know the city and state looping through them all like you did in your original post in the old thread is the easiest way to do that. If your array is that big you should just use a database as it would be far easier to query the data however you want.

mathceleb
06-01-2011, 09:48 PM
If you don't know the city and state looping through them all like you did in your original post in the old thread is the easiest way to do that. If your array is that big you should just use a database as it would be far easier to query the data however you want.

Thanks, that is a great idea.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum