Fw: [PHP] Re: adding info to an array?

From: Date: Thu, 01 Aug 2002 21:40:44 +0000
Subject: Fw: [PHP] Re: adding info to an array?
Groups: php.general 
Request: Send a blank email to php-general+get-110745@lists.php.net to get a copy of this message
It's all in the manual.. http://www.php.net Each one of these methods will assign two strings to the array and print the string, "mysecondvalue". -- $ra = array ("myfirstvalue", "mysecondvalue"); echo $ra[1]; -- $ra = array(); $ra[] = "myfirstvalue"; $ra[] = "mysecondvalue"; echo $ra[1]; -- $ra[0] = "myfirstvalue"; $ra[1] = "mysecondvalue"; echo $ra[1]; -- $ra = array("a" => "myfirstvalue", "b" => "mysecondvalue"); echo $rap[b]; -- $ra = array("myfirstvalue"); array_push($ra, "mysecondvalue"); echo $ra[1]; -- -Kevin ----- Original Message ----- From: "Hawk" <hw2k@barrysworld.com> To: <php-general@lists.php.net> Sent: Thursday, August 01, 2002 3:17 PM Subject: [PHP] Re: adding info to an array? > Tried that now, and with the same results > print_r($ra); still only shows the last info inserted in the array :/ > > "Aaron" <aaron_ott@hotmail.com> skrev i meddelandet > news:20020801211307.65119.qmail@pb1.pair.com... > > just assign the value to $ra[] > > > > > > "Hawk" <hw2k@barrysworld.com> wrote in message > > news:20020801210856.61486.qmail@pb1.pair.com... > > > I have a for loop, and an if that checks something, and if true, it's > > > supposed to add info to an array called $ra, but instead of adding it to > > the > > > array it seems like it's overwriting it, currently I'm using $ra[$r] = > > > "$r"; where $r is a number.. > > > after the for } I put a print_r($ra); and it only prints the last thing > > that > > > was added to the array. How do I solve this? Haven't used arrays much so > > I'm > > > trying to learn, but it's not going very well :) > > > > > > Håkan > > > > > > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#110745) next »