Generate HTML Table From PHP Array
I have the following PHP array queried from my mySQL Database in $array: Print_r with pre tags gives me: Array ( [A] => 1 [B] => 2 ) This should be nicely formatted i
Solution 1:
Just because it's easy:
$array = array("A" => "1", "B" => "2");
echo "<table>";
foreach( $array as $key => $value ){
echo "<tr><td>" . $key . "</td><td>" . $value . "</td></tr>";
}
echo "</table>";
But you should try before you ask here, then, if you have a problem, you can ask about it.
Post a Comment for "Generate HTML Table From PHP Array"