Skip to content

Instantly share code, notes, and snippets.

@JacobHsu
Created August 19, 2014 07:36
Show Gist options
  • Save JacobHsu/8af3c2b086c3ff5ffd16 to your computer and use it in GitHub Desktop.
Save JacobHsu/8af3c2b086c3ff5ffd16 to your computer and use it in GitHub Desktop.
#PHP -An associative array makes use of (key => value)
<html>
<head>
<title>Associate Arrays</title>
</head>
<body>
<p>
<?php
// This is an array using integers as the indices...
$myArray = array(2012, 'blue', 5);
// ...and this is an associative array:
$myAssocArray = array('year' => 2012,
'colour' => 'blue',
'doors' => 5);
// This code will output "blue"...
echo $myArray[1];
echo '<br />';
// ... and this will also output "blue"!
echo $myAssocArray['colour'];
?>
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment