Associative Arrays Contain Key Value Pairs | "name" => "chris"
array(7) { ["first_name"]=> string(5) "Chris" ["last_name"]=> string(3) "Tow" ["age"]=> string(2) "37" ["email"]=> string(19) "chris@christow.blog" ["city"]=> string(5) "Boise" ["state"]=> string(5) "Idaho" ["favorite_food"]=> string(10) "Vegan Food" }
array(7) { ["first_name"]=> string(4) "Inga" ["last_name"]=> string(8) "Aguinaga" ["age"]=> string(2) "38" ["email"]=> string(18) "inga@christow.blog" ["city"]=> string(5) "Boise" ["state"]=> string(5) "Idaho" ["favorite_food"]=> string(10) "Vegan Food" }
array(7) { ["first_name"]=> string(7) "Boobers" ["last_name"]=> string(3) "Cat" ["age"]=> string(1) "6" ["email"]=> string(21) "boobers@christow.blog" ["city"]=> string(5) "Boise" ["state"]=> string(5) "Idaho" ["favorite_food"]=> string(8) "Tofurkey" }
array(7) { ["first_name"]=> string(5) "Chomp" ["last_name"]=> string(0) "" ["age"]=> string(1) "3" ["email"]=> string(19) "chomp@christow.blog" ["city"]=> string(8) "Meridian" ["state"]=> string(5) "Idaho" ["favorite_food"]=> string(15) "Iceberg Lettuce" }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../styles.css">
<title>PHP: Associative Arrays</title>
</head>
<body>
<h1 class="lesson-hr">PHP: Associative Arrays</h1>
<h4>Below is an Associative Array of People</h4>
<p>Associative Arrays Contain Key Value Pairs | "name" => "chris"</p>
<?php
$people = [
[
'first_name'=>'Chris',
'last_name'=>'Tow',
'age'=>'37',
'email'=>'chris@christow.blog',
'city'=>'Boise',
'state'=>'Idaho',
'favorite_food'=>'Vegan Food'
],
[
'first_name'=>'Inga',
'last_name'=>'Aguinaga',
'age'=>'38',
'email'=>'inga@christow.blog',
'city'=>'Boise',
'state'=>'Idaho',
'favorite_food'=>'Vegan Food'
],
[
'first_name'=>'Boobers',
'last_name'=>'Cat',
'age'=>'6',
'email'=>'boobers@christow.blog',
'city'=>'Boise',
'state'=>'Idaho',
'favorite_food'=>'Tofurkey'
],
[
'first_name'=>'Chomp',
'last_name'=>'',
'age'=>'3',
'email'=>'chomp@christow.blog',
'city'=>'Meridian',
'state'=>'Idaho',
'favorite_food'=>'Iceberg Lettuce'
]
];
echo "<pre>";
foreach($people as $person){
echo var_dump($person);
echo "<hr>";
}
echo "</pre>";
include('../show_code.php');
show_code('index.php');
?>
</body>
</html>