...

View Full Version : foreach through a double array?



thesavior
04-03-2007, 02:26 AM
Here is my array:


$options = array(
"funcs" => array("standard_funcs" => 'functions'),
"diff_funcs" => array("standard_funcs" => 'diff_functions'),
"vars" => array("special_vars" => 'vars'),
);


I want to do a foreach through that
Do i do something like:



foreach ($options as $call => $filename => $classname)

// or

foreach ($options as $call => ($filename => $classname))


or what. Is this even possible?

iLLin
04-03-2007, 03:45 AM
foreach($options as $array) {
foreach($array as $value) {
}
}

thesavior
04-04-2007, 03:55 PM
that wont work, because I need to be able to use all three values in the same place.

iLLin
04-04-2007, 03:56 PM
What output are you looking for?

aedrin
04-04-2007, 04:04 PM
The example that iLLin posted should do what you want.



foreach($options as $call => $array) {
foreach($array as $filename => $classname) {
// $call, $filename and $classname are all available here.
// first: $call = "funcs", $filename = "standard_funcs", $classname = "functions"
// etc.
}
}

iLLin
04-04-2007, 04:20 PM
Yea I was gonna post the keys, but wasn't sure of his desired output. What aedrin said up there ^^

thesavior
04-05-2007, 11:53 PM
thanks that did it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum