Re: [PHP] Re: Simple PHP setting arrays with keys question
Dan skrev: Oh yeah, the problem isn't that I'm using - instead of =. Well that was a problem but I fixed that and it's still not working. - Dan Dan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm having a little problem assigning a value to an array which has a key. It's simple, I just don't know what I'm doing wrong. foreach($Checkout as $value) { $products[] = $value['productName'] - $value['actualValue']; } HELP! either: $products[$value['productName']] = $value['actualValue']; OR $products[] = array( $value['productName'] = $value['actualValue'] ); -- /Thunis I think you ought to know I'm feeling very depressed. --The Hitchikers Guide to the Galaxy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple PHP setting arrays with keys question
Fredrik Thunberg wrote: Dan skrev: Oh yeah, the problem isn't that I'm using - instead of =. Well that was a problem but I fixed that and it's still not working. - Dan Dan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm having a little problem assigning a value to an array which has a key. It's simple, I just don't know what I'm doing wrong. foreach($Checkout as $value) { $products[] = $value['productName'] - $value['actualValue']; } HELP! either: $products[$value['productName']] = $value['actualValue']; OR $products[] = array( $value['productName'] = $value['actualValue'] ); But these are not the same... -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple PHP setting arrays with keys question
On 7/10/07, Jim Lucas [EMAIL PROTECTED] wrote: Fredrik Thunberg wrote: Dan skrev: Oh yeah, the problem isn't that I'm using - instead of =. Well that was a problem but I fixed that and it's still not working. - Dan Dan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm having a little problem assigning a value to an array which has a key. It's simple, I just don't know what I'm doing wrong. foreach($Checkout as $value) { $products[] = $value['productName'] - $value['actualValue']; } HELP! either: $products[$value['productName']] = $value['actualValue']; OR $products[] = array( $value['productName'] = $value['actualValue'] ); But these are not the same... -- Jim Lucas This one is: $products += array( $value['productName'] = $value['actualValue'] ); :) Tijnema -- Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple PHP setting arrays with keys question
Tijnema wrote: On 7/10/07, Jim Lucas [EMAIL PROTECTED] wrote: Fredrik Thunberg wrote: Dan skrev: Oh yeah, the problem isn't that I'm using - instead of =. Well that was a problem but I fixed that and it's still not working. - Dan Dan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm having a little problem assigning a value to an array which has a key. It's simple, I just don't know what I'm doing wrong. foreach($Checkout as $value) { $products[] = $value['productName'] - $value['actualValue']; } HELP! either: $products[$value['productName']] = $value['actualValue']; OR $products[] = array( $value['productName'] = $value['actualValue'] ); But these are not the same... -- Jim Lucas This one is: $products += array( $value['productName'] = $value['actualValue'] ); :) Tijnema well, I was leaving it up to Fredrik to figure out in what way they were different :) -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple PHP setting arrays with keys question
On 7/10/07, Jim Lucas [EMAIL PROTECTED] wrote: Tijnema wrote: On 7/10/07, Jim Lucas [EMAIL PROTECTED] wrote: Fredrik Thunberg wrote: Dan skrev: Oh yeah, the problem isn't that I'm using - instead of =. Well that was a problem but I fixed that and it's still not working. - Dan Dan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm having a little problem assigning a value to an array which has a key. It's simple, I just don't know what I'm doing wrong. foreach($Checkout as $value) { $products[] = $value['productName'] - $value['actualValue']; } HELP! either: $products[$value['productName']] = $value['actualValue']; OR $products[] = array( $value['productName'] = $value['actualValue'] ); But these are not the same... -- Jim Lucas This one is: $products += array( $value['productName'] = $value['actualValue'] ); :) Tijnema well, I was leaving it up to Fredrik to figure out in what way they were different :) -- Jim Lucas I'm sorry ;) I was a little too fast :) Tijnema -- Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple PHP setting arrays with keys question
Yeah I wanted $products[$value['productName']] = $value['actualValue'];. I've been working a lot in Delphi recently so my mind for PHP is somewhat messed up lately, missing easy things like this. - Dan brian [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Dan wrote: Oh yeah, the problem isn't that I'm using - instead of =. Well that was a problem but I fixed that and it's still not working. - Dan Dan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm having a little problem assigning a value to an array which has a key. It's simple, I just don't know what I'm doing wrong. foreach($Checkout as $value) { $products[] = $value['productName'] - $value['actualValue']; } Please don't top-post. This is a bit confusing. I'm guessing you want the $products array to use keys as the value of $value['productName']. If that's the case, you want: $products[$value['productName']] = $value['actualValue']; So, if $value looked like this in a foreach iteration: $value = Array('productName' = 'foo', 'actualValue' = 'bar') you'd have: $products['foo'] == 'bar'; Is that what you're looking for? brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple PHP setting arrays with keys question
Jim Lucas wrote: Fredrik Thunberg wrote: Dan skrev: Oh yeah, the problem isn't that I'm using - instead of =. Well that was a problem but I fixed that and it's still not working. - Dan Dan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm having a little problem assigning a value to an array which has a key. It's simple, I just don't know what I'm doing wrong. foreach($Checkout as $value) { $products[] = $value['productName'] - $value['actualValue']; } HELP! either: $products[$value['productName']] = $value['actualValue']; OR $products[] = array( $value['productName'] = $value['actualValue'] ); But these are not the same... I never said that they we're. Just wanted to show what he could do. :) /T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Simple PHP setting arrays with keys question
Oh yeah, the problem isn't that I'm using - instead of =. Well that was a problem but I fixed that and it's still not working. - Dan Dan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm having a little problem assigning a value to an array which has a key. It's simple, I just don't know what I'm doing wrong. foreach($Checkout as $value) { $products[] = $value['productName'] - $value['actualValue']; } HELP! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Simple PHP setting arrays with keys question
Oh yeah, the problem isn't that I'm using - instead of =. Well that was a problem but I fixed that and it's still not working. - Dan Dan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm having a little problem assigning a value to an array which has a key. It's simple, I just don't know what I'm doing wrong. foreach($Checkout as $value) { $products[] = $value['productName'] - $value['actualValue']; } HELP! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple PHP setting arrays with keys question
Dan wrote: Oh yeah, the problem isn't that I'm using - instead of =. Well that was a problem but I fixed that and it's still not working. - Dan Dan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm having a little problem assigning a value to an array which has a key. It's simple, I just don't know what I'm doing wrong. foreach($Checkout as $value) { $products[] = $value['productName'] - $value['actualValue']; } Please don't top-post. This is a bit confusing. I'm guessing you want the $products array to use keys as the value of $value['productName']. If that's the case, you want: $products[$value['productName']] = $value['actualValue']; So, if $value looked like this in a foreach iteration: $value = Array('productName' = 'foo', 'actualValue' = 'bar') you'd have: $products['foo'] == 'bar'; Is that what you're looking for? brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php