Write a PHP function (write the function only) to dynamically create an HTML table with m rows and n columns. m and n are function parameters. Other requirements: - Each column is 100 in width - The table and all cells should have visible borders - In each cell, please display the value of m and n aligned to the center. Solution function create_table($data) { $res = \'<table width=\"200\" border=\"1\">\'; $max_data = sizeof($data); $ctr = 1; foreach ($data as $db_data) { if ($ctr % 2 == 0) $res .= \'<td align=\"center\">\' . $db_data[\'id\']. \'</td></tr>\'; else { if ($ctr < $max_data) $res .= \'<tr><td align=\"center\">\' . $db_data[\'id\']. \'</td>\'; else $res .= \'<tr><td colspan=\"2\" align=\"center\">\' . $db_data[\'id\']. \'</td></tr>\'; } $ctr++; } return $res . \'</table>\'; } .
Write a PHP function (write the function only) to dynamically create an HTML table with m rows and n columns. m and n are function parameters. Other requirements: - Each column is 100 in width - The table and all cells should have visible borders - In each cell, please display the value of m and n aligned to the center. Solution function create_table($data) { $res = \'<table width=\"200\" border=\"1\">\'; $max_data = sizeof($data); $ctr = 1; foreach ($data as $db_data) { if ($ctr % 2 == 0) $res .= \'<td align=\"center\">\' . $db_data[\'id\']. \'</td></tr>\'; else { if ($ctr < $max_data) $res .= \'<tr><td align=\"center\">\' . $db_data[\'id\']. \'</td>\'; else $res .= \'<tr><td colspan=\"2\" align=\"center\">\' . $db_data[\'id\']. \'</td></tr>\'; } $ctr++; } return $res . \'</table>\'; } .