A.6. Chapter 6
Solution to Question 6-1 The first element is located in position 0 of the array.
Solution to Question 6-2 The $months array can be created as follows: <?php $months[]='January'; $months[]='February'; $months[]='March'; $months[]='April'; $months[]='May'; $months[]='June'; $months[]='July'; $months[]='August'; $months[]='September'; $months[]='October'; $months[]='November'; $months[]='December'; ?> The array() function is also correct: array('January,'February','March','April','May','June','July','August','September', 'October','November','December');
Solution to Question 6-3 To create the array with the days in each month: <?php $months= array('January' => 31, 'February' => 28, 'March' => 31, 'April' => 30, 'May' => 31, 'June' => 30, 'July' => 31, 'August' => 31, 'September' => 30, 'October' => 31, 'November' => 30, 'December' => 31); ?>
Solution to Question 6-4 To display the $months array: <?php $months= array('January' => 31, 'February' => 28, 'March' => 31, 'April' => 30, 'May' => 31, 'June' => 30, 'July' => 31, 'August' => 31, 'September' => 30, 'October' => 31, 'November' => 30, 'December' => 31); echo var_dump($months); ?> |