<?php
$array[2001][1] = array('wp' => 1, 's' => 2, 'c' => 3);
$array[2001][2] = array('wp' => 4, 's' => 5, 'c' => 6);
$array[2001][3] = array('wp' => 7, 's' => 8, 'c' => 9);
$array[2002][1] = array('wp' => 10, 's' => 11, 'c' => 12);
$array[2002][2] = array('wp' => 13, 's' => 14, 'c' => 15);
$array[2002][4] = array('wp' => 16, 's' => 17, 'c' => 18);
?>
<table border="1">
<tr>
<th></th>
<?php foreach ($array as $year => $months): ?>
<th><?=htmlspecialchars($year)?></th>
<?php endforeach; ?>
</tr>
<?php for ($monthNumber = 1; $monthNumber <= 12; $monthNumber++): ?>
<tr>
<th><?=htmlspecialchars($monthNumber)?></th>
<?php foreach ($array as $months): ?>
<?php if (isset($months[$monthNumber])): ?>
<td>wp: <?=htmlspecialchars($months[$monthNumber]['wp'])?>, s: <?=htmlspecialchars($months[$monthNumber]['s'])?>, c: <?=htmlspecialchars($months[$monthNumber]['c'])?></td>
<?php else: ?>
<td></td>
<?php endif; ?>
<?php endforeach; ?>
</tr>
<?php endfor; ?>
</table>