Re: Re: Simple PHP setting arrays with keys question
| From: | Dan | Date: | Tue, 10 Jul 2007 17:18:43 +0000 |
| Subject: | Re: Re: Simple PHP setting arrays with keys question | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258559@lists.php.net to get a copy of this message | ||
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" <phplist@subtropolix.org> wrote in message news:4692E26F.5040301@subtropolix.org...
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"" <frozendice@gmail.com> wrote in message news:93.D2.03277.CF2D2964@pb1.pair.com...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? brianI'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']; }