Making An HTML5 Table From An Associative Array In PHP - An Easy Tutorial

Last Edited: 2015-12-30 18:45:07

Hi there!  Many times I am faced with a bunch of data that I need to make into a table.  Usually my data is in a database, but there are times in which I am making a website and need to store some data, but don't have a database available.  Making tables is kind of a drag, but making programming datastructers are not as bad!  Arrays are some of the most common types of datastructures you're going to run across in most programming languages.  The are basically variables that hold "sets" of information.  A simple array in PHP could be defined like this:

$myArray = Array('dogs','snacks','wagons','crackers');

That's what it would look like in the code. In PHP, you can use the built in function print_r($myArray); to print that puppy out

echo "<pre>";
//would output this:
Array = (
[0] => 'dogs',
[1] => 'snacks',
[2] => 'wagons',
[3] => 'crackers'



Recent Posts