Reputation: 69
How to print array data in table format with appropriate table head and data. Or in DIV also
<!DOCTYPE html>
<html>
<head>
<title>Array</title>
</head>
<body>
<?php
$arr = array
(
array("U Jadeja",100,100),
array("A Dave",200,200),
array("K Lathiya",300,300),
array("A Kanani",400,400),
array("Brock lesnar",400,400),
);
?>
<
</body>
</html>
Upvotes: 0
Views: 95
Reputation: 69
It works...
<!DOCTYPE html>
<html>
<head>
<title>Array</title>
</head>
<body>
<?php
$arr = array
(
array("Upendrasinh",100,100),
array("Ankit dave",200,200),
array("Krunal Lathiya",300,300),
array("Arjun Kanani",400,400),
);
$arrCount = count($arr);
// $arrsubcount = count($arr[0]);
// echo $arrsubcount;
// echo "<br>";
$arraycell=count($arr[0][0]);
$arraycell=$arraycell;
echo '<table border="5px" width="100%">';
echo "<tr>";
echo "<th>Name</th>";
echo "<th>Score</th>";
echo "<th>Score2</th>";
echo "</tr>";
for($arrayrow=0;$arrayrow<=$arrCount-1;$arrayrow++){
echo "<tr>"."<td>".$arr[$arrayrow][0]. "</td>";
for($arraycolumn=0;$arraycolumn<$arraycell;$arraycolumn++){
echo "<td>".$arr[$arrayrow][$arraycell]."</td>";
echo "<td>".$arr[$arrayrow][$arraycell+1]."</td>"."</tr>";
}
}
echo '</table>';
?>
</body>
</html>
Upvotes: 1