PHP Arrays Example
Below is our first example with arrays. We’ll update this file when we completely finish with the example.
<!DOCTYPE html>
<html>
<head>
<title>Third PHP Example</title>
</head>
<body>
<?php
// Ask PHP to print all errors and warnings
// This is very helpful when developing
error_reporting(E_ALL);
ini_set('display_errors', 1);
$trivia = [
"largest" => "What is the largest desert in the world?",
"45" => "Who invented gravity?",
"mammal" => "What is the smallest mammal in the world?"
];
array_push($trivia, "What animal has square poop?");
print_r($trivia);
var_dump($trivia);
foreach ($trivia as $k => $qn) {
echo "Question $k: $qn<br>\n";
}
?>
</body>
</html>