[nycphp-talk] Please assist w/simple associative array problem?
Jeff Knight
jeff.knight at gmail.com
Fri Nov 10 16:34:57 EST 2006
On 11/10/06, R. Mariotti <r.mariotti at fdcx.net> wrote:
> here's what the array looks like:
>
> $agx=array( 'back_door' => '0',
> 'front_door' => '1',
> 'side_door' => '0',
> 'garage_door' => '1'
> );
>
> I have tried various permutations of the while(list($k,$v... and
> foreach($atx as $v => $k)
for your array $atx,
foreach ($agx as $key => $value) {
echo "$key is set to $value\n";
}
will give you the output:
back_door is set to 0
front_door is set to 1
side_door is set to 0
garage_door is set to 1
Note that in your example foreach $v is in the key position & $k is in
the value, but that's probably a typo in your email & not your code.
Since you "don't know the current values of the keys", are you sure
that the keys of the $atx array are set as you suspect? Try a
print_r($atx) and see what you are starting with.
More information about the talk
mailing list