Skip to content

Instantly share code, notes, and snippets.

@lizettepreiss
Created July 3, 2016 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizettepreiss/2391a614f530a9ab8779aa49421ef592 to your computer and use it in GitHub Desktop.
Save lizettepreiss/2391a614f530a9ab8779aa49421ef592 to your computer and use it in GitHub Desktop.
PHP Associative Arrays
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
//or
$age['Peter'] = "35";
$age['Ben'] = "37";
$age['Joe'] = "43";
echo "Peter is " . $age['Peter'] . " years old.";
foreach($age as $x => $x_value) {
echo "Key=" . $x . ", Value=" . $x_value;
echo "<br>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment