/////////////////////////////////////////////Task 3 /////////////////////////////////////////
ECHO '
Task 3:
';
//Show_Table produces the ouput based on the (rectangular) array of arrays.
function Show_Table($ArrayTableData){
$strHtmlTable = '';
$strHtmlTable = $strHtmlTable . '';
$maxRows = 0;
$TeamCount = 0;
//Loop through all of the Group Array data to add the heading row.
foreach($ArrayTableData as $Groups => $Teams)
{
$strHtmlTable = $strHtmlTable . '| '. $Groups .' | ';
$TeamCount++;
//This will determine the group with the maximum teams.
if ($maxRows < Count($Teams))
{
$maxRows = Count($Teams)-1;
}
}
$strHtmlTable = $strHtmlTable . '
';
//Now loop through all Teams Arrays and start to output the rows of data.
for($currentRow=0;$currentRow <= $maxRows; $currentRow++)
{
$strHtmlTable = $strHtmlTable . '';
foreach($ArrayTableData as $Groups => $Teams)
{
if($currentRow < Count($Teams))
{
$strHtmlTable = $strHtmlTable .'| '. $Teams[$currentRow] .' | ';
}
else
{
$strHtmlTable = $strHtmlTable .' | ';
}
}
$strHtmlTable = $strHtmlTable .'
';
}
$strHtmlTable = $strHtmlTable .'
';
echo $strHtmlTable;
}
//Create an (Rectangular)array of arrays.
$arrTable_Data;
$arrTable_Data["Group A - Bata"] = array("Equatorial Guinea","Congo-Brazzaville","Gabon","Burkina Faso");
$arrTable_Data["Group B - Ebebiyin"] = array("Zambia","DR Congo","Cape Verde","Tunisia");
$arrTable_Data["Group C - Mongomo"] = array("Ghana","Senegal","South Africa","Algeria");
$arrTable_Data["Group D - Malabo"] = array("Ivory Coast","Guinea","Cameroon","Mali");
//Call the show table function to display the data
Show_Table($arrTable_Data);