[nycphp-talk] Please assist w/simple associative array problem?
Sean
sean712 at gmail.com
Fri Nov 10 16:16:07 EST 2006
nothing seems wrong to me.
On 11/10/06, Andy Dirnberger <dirn at dirnonline.com> wrote:
>
> This works for me:
>
> <?php
> $agx = array ('back_door' => '0',
> 'front_door' => '1',
> 'side_door' => '0',
> 'garage_door' => '1');
> foreach ($agx as $k => $v) {
> echo "\$agx ['{$k}'] = {$v}\n";
> }
> ?>
>
> Output:
> $agx ['back_door'] = 0
> $agx ['front_door'] = 1
> $agx ['side_door'] = 0
> $agx ['garage_door'] = 1
>
> DiRN
>
> -----Original Message-----
> From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
> On
> Behalf Of R. Mariotti
> Sent: Friday, November 10, 2006 3:56 PM
> To: talk at lists.nyphp.org
> Subject: [nycphp-talk] Please assist w/simple associative array problem?
>
> Gentlemen;
>
> I know its late Fri afternoon - but hopefully before everyone splits for
> the weekend someone can help me close this one?
>
> I am trying to process an entire array referencing all the elements both
> keys and values. I don't know the current values of the keys and that's
> why I have to "walk" through them.
>
> 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)
>
> and all I get are the numeric indexes of the elements as:
>
> 0 = 0
> 1 = 1
> 2 = 0
> 3 = 1
>
> What I NEED to extract for EACH iteration are:
> $k = 'back_door', $v = 0
> $k = 'front_door', $v = 1
> $k = 'side_door' , $v = 0
> $k = 'garage_door', $v = 1
>
> In the interest of time, can SOMEONE PLEASE provide some guidance as to
> the best way (code-wise) to accomplish this?
>
> Thanks a million on a nice Friday afternoon.
>
> bobmct
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20061110/7028ab89/attachment.html>
More information about the talk
mailing list