Quotes help make search much faster. Example: "Practice Makes Perfect"

Friday, April 26, 2013

Codecademy Sample Solution: Accessing Associative Arrays



<html>
  <head>
    <title>Accessing Associative Arrays</title>
  </head>
  <body>
    <p>
      <?php
        // This is an array using integers as the indices...
        $myArray = array(2012, 'blue', 5, 'BMW');

        // ...and this is an associative array:
        $myAssocArray = array('year' => 2012,
                        'colour' => 'blue',
                        'doors' => 5,
                        'make' => 'BMW');
           
        // This code will output "blue".
        echo $myArray[1];
        echo '<br />';
           
        // Add your code here!
        echo "My car was purchased in $myArray[0] and has ". $myAssocArray['doors'] ." doors.";
      ?>
    </p>
  </body>
</html>

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts