Created
August 19, 2014 07:36
-
-
Save JacobHsu/8af3c2b086c3ff5ffd16 to your computer and use it in GitHub Desktop.
#PHP -An associative array makes use of (key => value)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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