View Single Post
Old 06-28-2009, 10:17 PM   #6 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,324
Thanks: 5
Salathe is on a distinguished road
Default

Your example array, in the first post, must not be the exact array that your code is using else Wildhoney's snippet would have worked.

If the array is modified to what I think you might actually be using (based on the post just before this one) then the following code should help:
PHP Code:
$array = array
(
    
'warranty' => array
    (
        
'warranty15' => array('id' => '15 year''text' => '15 Years'),
        
'warranty20' => array('id' => '20 year''text' => '20 Years'),
        
'warranty25' => array('id' => '25 year''text' => '25 Years')
    )
);

foreach (
$array as $label => $warranties)
{
    
// "warranty"
    
echo $label."\n";
    foreach (
$warranties as $key => $warranty)
    {
        
// e.g. "warranty15 - 15 year - 15 Years<br>"
        
echo $key.' - '.$warranty['id'].' - '.$warranty['text']."\n";
    }

Which outputs:
warranty
warranty15 - 15 year - 15 Years
warranty20 - 20 year - 20 Years
warranty25 - 25 year - 25 Years
Salathe is offline  
Reply With Quote