Arrays 5/7

Access by Offset with { }
PHP is a very flexible language. When accessing arrays by offset, you can actually use two different types of syntax: the []syntax we've covered, or you can use curly braces ({}). You use the curly braces just like you use the square brackets:
<?php
 $myArray = array("do", "re", "mi");
 print $myArray{2};
 // prints "mi";
?>
Both forms are equivalent, and using one or the other is totally up to you!
Instructions
Go ahead and update your previous code to use the {} syntax instead of [].
?
Hint
Test how well you're learning and fill in gaps with Codecademy Pro.Learn more.
All you need to do is replace [ with { and] with }.
Arrays 5/7
<html>
  <head>
    <title>Accessing Elements</title>
  </head>
  <body>
    <p>
      <?php
        $tens = array(10, 20, 30, 40, 50);
        echo $tens{2};
      ?>
    </p>
  </body>
</html>

Comments

Popular posts from this blog

MEGA 暫存檔案刪除

IOS GCD多執行緒

利用CMD指令強制刪除