Link to home
Start Free TrialLog in
Avatar of spcjcp
spcjcp

asked on

Display Array

This should be a simple one, but am having difficulties. I have this array:


Array
(
    [81] => Array
        (
            [36] => No
            [pagetitle] => Registration and Hospitality open
            [19] => 8:00 AM
        )

    [82] => Array
        (
            [36] => No
            [pagetitle] => Workshops
            [19] => 8:30 AM
        )

    [207] => Array
        (
            [24] => Workshop
            [pagetitle] => Creating, Growing and Managing a Chapter Endowment
            [19] => 8:30 AM
            [27] => 227
        )
)


And want to display the data like this:

81 - No - Registration and Hospitality open - 8:00 AM - -
82 - No - Workshops - 8:30 AM - -
207 - - Creating, Growing and Managing a Chapter Endowment - 8:30 AM - 227


Thanks in Advance!
Avatar of kaufmed
kaufmed
Flag of United States of America image

Try this out:

echo "<pre>";

foreach ($source as $key => $value) {
   echo "$key -";
   
   foreach ($value as $v) {
      echo " - $v";
   }
   
   echo "\n";
}

 
echo "</pre>";

Open in new window


Where $source represents the original array.
ASKER CERTIFIED SOLUTION
Avatar of Derokorian
Derokorian
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do you really want the double dashes at the end of the strings?  You might consider using implode(' - ', $v) on the sub-arrays to make a display string with dashes between the data elements.
Avatar of spcjcp
spcjcp

ASKER

Perfect - thanks!