Re: makeing an array

From: Date: Wed, 01 Jan 2003 05:29:49 +0000
Subject: Re: makeing an array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-129826@lists.php.net to get a copy of this message
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)" <phplists@hitcho.com.au> To: "Philip J. Newman" <newmanpj@philipnz.com>; <php-general@lists.php.net> 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) > tim@hitcho.com.au > > > HiTCHO | Open Platform Web Development > Consulting - Outsourcing - Training - Support > > > ----- Original Message ----- > From: "Philip J. Newman" <newmanpj@philipnz.com> > To: <php-general@lists.php.net> > 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/ > > info@philipnz.com > > > > Mob: +64 (25) 6144012. > > Tele: +64 (9) 5769491. > > > > VitalKiwi Site: > > Philip J. Newman > > Internet Developer > > http://www.newman.net.nz/ > > info@newman.net.nz > > > > ***************************** > > Friends are like Stars, > > You can't always see them, > > But you know they are there. > > > > ***************************** > > > > ICQ#: 20482482 > > MSN ID: philipsdomain@hotmail.com > > Yahoo: philip_newman@yahoo.com > > 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 >

« previous php.general (#129826) next »