Tutorial 7: Associative Arrays


Remember how PHP automatically assigns a number to each item in an array? Well, using Associative Arrays you can give a custom name to the key, rather than using a number. It looks like this:

$handlebar = array(
				
				"name" => "Handlebar",
				
				"creep_factor" => "High",
				
				"avg_growth_days" => 14
				
			);

Now, let's say I wanted to display specific information from the array. I would do so by simply referring to a custom key in the array, like this:

<?php echo $handlebar["creep_factor"]; ?>
Check out the final example
©2025 Brad Hussey