Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created August 17, 2020 22:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
[ Posted by Sohaib Karim ] PHP 1D And 2D Array in Table Format
<?php
$movies = array(
array('Bad Boys For Life' , 'Comedy' , 'Mike Judge' ),
array('To Little' , 'Action' , 'Andy / Larry Wachowski' ),
array('Jumanji The Next Level' , 'Comedy / Adventure' , 'Sofia Coppola' ),
array('IP Man 4' , 'Action' , 'Ron Howard' ),
array('SpiderMan Far From Home' , 'Adventure' , 'Jared Hess' )
);
echo '<table border="1">';
echo '<tr>
<th>Movies</th>
<th>Genre</th>
<th>Director</th>
</tr>';
foreach( $movies as $movie )
{
echo '<tr>';
foreach( $movie as $key )
{
echo '<td>'.$key.'</td>';
}
echo '</tr>';
}
echo '</table>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment