Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here you are:</p> <pre><code>&lt;?php // [your array] $tabledata = array( 'Media' =&gt; array( '2012-12-10' =&gt; array( 'Mentor' =&gt; 'Evan Tobin', 'Veteran Member' =&gt; 'James' ), '2012-12-21' =&gt; array( 'Mentor' =&gt; 'Evan Tobin' ) ), 'Website' =&gt; array( '2012-12-10' =&gt; array( 'Mentor' =&gt; 'Evan Tobin' ), '2012-12-21' =&gt; array( 'Mentor' =&gt; 'Evan Tobin' ) ) ); // [/your array] // [the tables] echo '&lt;table border="1"&gt;'; foreach($tabledata as $teamkey =&gt; $teamval){ // [helper] $dates = array(); $roles = array(); foreach($teamval as $datekey =&gt; $dateval) { if (!in_array($datekey, $dates)) { $dates[] = $datekey; } foreach($dateval as $rolekey=&gt;$roleval) { if (!in_array($rolekey, $roles)) { $roles[] = $rolekey; } } } // [/helper] // [team name] &gt;&gt; row 1 echo '&lt;tr&gt;'; echo '&lt;th align="left" colspan="'.(sizeof($dates)+1).'"&gt;'.$teamkey.' Team&lt;/th&gt;'; echo '&lt;/tr&gt;'; // [/team name] // [role column and date column] &gt;&gt; row 2 echo '&lt;tr&gt;'; echo '&lt;td&gt;Role&lt;/td&gt;'; foreach($dates as $date) { echo '&lt;td&gt;'.$date.'&lt;/td&gt;'; } echo '&lt;/tr&gt;'; // [/role column and date column] // [role and team member for each date] &gt;&gt; row 3, 4, 5, ... n foreach($roles as $role) { echo '&lt;tr&gt;'; echo '&lt;td&gt;'.$role.'&lt;/td&gt;'; foreach($dates as $date) { echo '&lt;td&gt;'; if (isset($teamval[$date][$role])) { echo $teamval[$date][$role]; // team member name } else { echo '&amp;nbsp;'; // insert blank space for cross browser support } echo '&lt;/td&gt;'; } echo '&lt;/tr&gt;'; } // [/role and team member for each date] } echo '&lt;/table&gt;'; // [/the tables] </code></pre> <p>If you want separate tables for each team, you can put the into the loop.</p> <p>Hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload