Sunday, April 29, 2012

PHP Arrays with Loops Tutorial


Arrays with Loops
Example: 1
        <?php
          
            $people = array('Oliva', 'Nicole', 'Natasha');
           for ($x=0; $x<sizeof($people); $x++)
           echo $people[$x]."<br />";
        ?>
Output
Oliva
Nicole
Natasha

Another way
Example: 2
        <?php
            
         $people = array('Oliva', 'Nicole', 'Natasha');
           foreach ($people as $x)
           echo $x."<br />";
         
        ?>
Output
Oliva
Nicole
Natasha

No comments:

Post a Comment