Your example of: for ($i = 0; $i < count($comment); $i++)
Is very bad as the count will be parsed each loop. The count as I had it gets parsed only once. Timothy Hitchens (HiTCHO) [EMAIL PROTECTED] HiTCHO | Open Platform Web Development Consulting - Outsourcing - Training - Support ----- Original Message ----- From: "Sean Malloy" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, January 01, 2003 9:40 PM Subject: RE: [PHP] makeing an array > why the $x variable aswell?! > > for ($i = 0; $i < count($comment); $i++) > { > echo $comment[$i].'<br />'; > } > > or even faster: > > $i = count($comment); > while ($i--) > { > echo $comment[$i].'<br />'; > } > > > -----Original Message----- > > From: Timothy Hitchens (HiTCHO) [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, 1 January 2003 4:41 PM > > To: Philip J. Newman; [EMAIL PROTECTED] > > Subject: Re: [PHP] makeing an array > > > > > > Use the count like following inside to ensure that you don't > > call on a non existent index. > > > > for ($i = 0, $x = count($comment); $i < $x; $i++) > > { > > echo $comment[$i].'<br />'; > > } > > > > Why do you want to echo out $comment_1 ??? > > > > > > > > Timothy Hitchens (HiTCHO) > > [EMAIL PROTECTED] > > > > > > HiTCHO | Open Platform Web Development > > Consulting - Outsourcing - Training - Support > > > > > > ----- Original Message ----- > > From: "Philip J. Newman" <[EMAIL PROTECTED]> > > To: "Timothy Hitchens (HiTCHO)" <[EMAIL PROTECTED]>; > > <[EMAIL PROTECTED]> > > Sent: Wednesday, January 01, 2003 3:29 PM > > Subject: Re: [PHP] makeing an array > > > > > > > So in saything that I could do this ... > > > > > > $s = 10 > > > > > > $comment[1] = '$comment_1'; > > > $comment[2] = '$comment_2'; > > > $comment[3] = '$comment_2'; > > > > > > for($i = 0; $i <= $s; $i++) { > > > > > > echo $comment[$i]."<br>"; > > > > > > } > > > > > > > > > > > > ----- Original Message ----- > > > From: "Timothy Hitchens (HiTCHO)" <[EMAIL PROTECTED]> > > > To: "Philip J. Newman" <[EMAIL PROTECTED]>; > > <[EMAIL PROTECTED]> > > > Sent: Wednesday, January 01, 2003 6:12 PM > > > Subject: Re: [PHP] makeing an array > > > > > > > > > > Example of an Array: > > > > > > > > $my_first_array = array(1 => 'first', 2 => 'second', 3 => 'third'); > > > > > > > > You can now access these like so: > > > > > > > > echo $my_first_array[1]; etc etc > > > > > > > > of if you had this: $my_first_array = array('first_name' => 'Philip', > > > > 'last_name' => 'Newman'); > > > > > > > > You could do this: > > > > > > > > echo $my_first_array['first_name']; > > > > > > > > The thing to remember is that array's start at 0 "see below!!" (I > > started > > > at > > > > 1 at the top to make it easier). > > > > > > > > You can also make an array like so: > > > > > > > > $first[] = 'Philip'; > > > > $first[] = 'John'; > > > > $first[] = 'Paul'; > > > > > > > > Now you can simply do: > > > > > > > > echo $first[0]; // this could output 'Philip'; > > > > > > > > You can then look at multi dimensional etc... > > > > > > > > I trust this get's you on your way. > > > > > > > > > > > > Timothy Hitchens (HiTCHO) > > > > [EMAIL PROTECTED] > > > > > > > > > > > > HiTCHO | Open Platform Web Development > > > > Consulting - Outsourcing - Training - Support > > > > > > > > > > > > ----- Original Message ----- > > > > From: "Philip J. Newman" <[EMAIL PROTECTED]> > > > > To: <[EMAIL PROTECTED]> > > > > Sent: Wednesday, January 01, 2003 2:57 PM > > > > Subject: [PHP] makeing an array > > > > > > > > > > > > > Can someone help me make an array ... > > > > > > > > > > I have $foo amount of loops to preform (1-20), and would > > like to make > > > the > > > > > veriable work for me like $comment_1, $comment_2 etc etc. > > > > > > > > > > http://nz.php.net/manual/en/function.array.php makes no sence to me > > > after > > > > i > > > > > read it and read it ... > > > > > > > > > > help me please > > > > > > > > > > --- > > > > > Philip J. Newman. > > > > > Head Developer. > > > > > PhilipNZ.com New Zealand Ltd. > > > > > http://www.philipnz.com/ > > > > > [EMAIL PROTECTED] > > > > > > > > > > Mob: +64 (25) 6144012. > > > > > Tele: +64 (9) 5769491. > > > > > > > > > > VitalKiwi Site: > > > > > Philip J. Newman > > > > > Internet Developer > > > > > http://www.newman.net.nz/ > > > > > [EMAIL PROTECTED] > > > > > > > > > > ***************************** > > > > > Friends are like Stars, > > > > > You can't always see them, > > > > > But you know they are there. > > > > > > > > > > ***************************** > > > > > > > > > > ICQ#: 20482482 > > > > > MSN ID: [EMAIL PROTECTED] > > > > > Yahoo: [EMAIL PROTECTED] > > > > > AIM: newmanpjkiwi > > > > > > > > > > > > > > > -- > > > > > PHP General Mailing List (http://www.php.net/) > > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php