Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Posts
    184
    Thanks
    68
    Thanked 2 Times in 2 Posts

    simple example I dont understand:

    Code:
    <?php
       
       $months = array("January", "February", "March", "April", "May");
       
       $a = 0;
       
       $b = count($months); 
       
       while($a < $b) {
          echo $months[$a], "<br />";
          ++$a;
       }
    ?>
    Elements in the array are assigned a number 0, 1, 2 etc... I did not think about that. I think I get it now. Thank you.
    Last edited by joliett89; 08-23-2011 at 08:58 PM. Reason: It would be good if I could erase the topic all together. Not sure if I can. Thank you.

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,313
    Thanks
    4
    Thanked 207 Times in 204 Posts
    A simpler way of looking at/doing it (IMO):

    PHP Code:
    $months = array("January""February""March""April""May");

    foreach (
    $months as $month) {
        print 
    $month '<br /';

    Dave .... HostMonster for all of your hosting needs


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •