Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-23-2011, 07:39 PM   PM User | #1
joliett89
Regular Coder

 
Join Date: Jul 2011
Posts: 172
Thanks: 64
Thanked 2 Times in 2 Posts
joliett89 has a little shameless behaviour in the past
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 07:58 PM.. Reason: It would be good if I could erase the topic all together. Not sure if I can. Thank you.
joliett89 is offline   Reply With Quote
Old 08-24-2011, 01:10 PM   PM User | #2
djm0219
Senior Coder

 
djm0219's Avatar
 
Join Date: Aug 2003
Location: Wake Forest, North Carolina
Posts: 1,227
Thanks: 2
Thanked 189 Times in 187 Posts
djm0219 is on a distinguished road
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
djm0219 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:14 PM.


Advertisement
Log in to turn off these ads.