Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created August 17, 2020 22:00
Show Gist options
  • Save phpfiddle/f1c43f6645f766b761f611a7a371af00 to your computer and use it in GitHub Desktop.
Save phpfiddle/f1c43f6645f766b761f611a7a371af00 to your computer and use it in GitHub Desktop.
[ 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