Added Control Structures: Loops
[sandbox.git] / php_sandbox / pointers.php
blob82a9c4830f22a0af9a185931f9fcc6785c7a5215
1 <html>
2 <head>
3 <title>Loops: pointers</title>
4 </head>
5 <body>
6 <?php
7 $ages = array(4, 8, 15, 16, 23, 42);
8 ?>
9 <?php
10 echo "1: " . current($ages) . "<br />";
11 next($ages);
12 echo "2: " . current($ages) . "<br />";
13 reset($ages);
14 echo "3: " . current($ages) . "<br />";
16 <br />
17 <?php
18 // while loop that moves the arrat pointer
19 while ($age = current($ages)) {
20 echo $age . ", ";
21 next($ages);
24 </body>
25 </html>