Write and test a function that takes an array of planet moons, indexed by the planet name (see below) and prints it out as an ordered list of planets, where all planets that have moons are followed by an ordered list of moons. Also, for each planet print out how many moons it has.
Here is the data array, copy/paste it into your program.
<?php
// larger moons of planets of Solar system (those bigger than 45 km in diameter)
// Source: http://en.wikipedia.org/wiki/Planet
$moons = array("Mercury" => array(),
"Venus" => array(),
"Earth" => array("Moon"),
"Mars" => array("Phobos","Deimos"),
"Jupiter" => array("Metis", "Amalthea","Thebe", "Io", "Europa",
"Ganymede", "Callisto", "Himalia", "Elara", "Carme", "Pasiphae"),
"Saturn" => array("Prometheus", "Pandora", "Epimetheus",
"Janus", "Mimas", "Enceladus", "Tethys", "Dione", "Rhea",
"Titan", "Hyperion", "Iapetus", "Phoebe"),
"Uranus" => array("Bianca", "Cressida", "Desdemona", "Juliet",
"Portia","Rosalind","Belinda","Puck","Miranda","Ariel",
"Umbriel","Titania", "Oberon", "Caliban", "Sycorax"),
"Neptune" => array("Naiad", "Thalassa", "Despina", "Galatea",
"Larissa", "Proteus", "Triton", "Nereid"));
?>
The output should start like this:
if ($array == array())
where instead of $array you use the array that you want to check.
add_moon($moons, "Saturn", "Siarnaq");
will add Siarnaq to the array of Saturn's moons. Use the function that
you wrote for question 1 to test the add_moon function.
Important hints:
This page is a part of CSci 1101 course web site.