RE: [PHP-DB] RE: adding in arrays
> -Original Message- > From: Martin Allan Jensen [mailto:[EMAIL PROTECTED]] > Sent: 10 December 2002 12:41 > > But, now i need to make another loop where it takes the key > [2000] and put's it into $year and takes the value 300 and > put it into $value > Can you help me with it, am really not good at arrays. Is this what you want: foreach ($array as $year=>$value): // do stuff endforeach; > > Array ( [2000] => 300 [2002] => 740 [2003] => 200 [2004] => > 150 [2005] => 250 ) Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: adding in arrays
> But, now i need to make another loop where it takes the key [2000] > and put's it into $year and takes the value 300 and put it into > $value > Can you help me with it, am really not good at arrays. you can assign the variables like this: $year = '2000' $value = array['2000'] //gets the element in the array with key '2000' -Peter -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: adding in arrays
IT WORKS!!! Really GJ...! But, now i need to make another loop where it takes the key [2000] and put's it into $year and takes the value 300 and put it into $value Can you help me with it, am really not good at arrays. Array ( [2000] => 300 [2002] => 740 [2003] => 200 [2004] => 150 [2005] => 250 ) THANKS again - Original Message - From: "Radovan Radic" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 1:19 PM Subject: [PHP-DB] Re: adding in array > > "Bastian Vogt" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > Lets say $year is 2000 > > > There is not defined index 2000 at $array. > > > It is going to be undefined offset. > > > > Hm... I think it's gonna work, but if it's one of the "don'ts" in > > progamming style, could you tell me why you shouldn't do this and how to > > make it better (and nice)? > > > > Regards, > > Bastian > > > I would write it if i knew it, but i have problems myself about it :( > Radovan > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >