PHP Array
PHP Array
❮ PreviousNext ❯
or:
$age['Peter'] = "35";
$age['Ben'] = "37";
$age['Joe'] = "43";
Example
<?php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
echo "Peter is " . $age['Peter'] . " years old.";
?>
Try it Yourself »
Example
<?php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
The reference contains a brief description, and examples of use, for each
function!
PHP Exercises
Test Yourself With Exercises
Exercise:
Create an associative array containing the age of Peter, Ben and Joe.
Source : https://www.w3schools.com/php/php_arrays_associative.asp