NYCPHP Meetup

NYPHP.org

[nycphp-talk] Please assist w/simple associative array problem?

R. Mariotti r.mariotti at fdcx.net
Fri Nov 10 15:56:02 EST 2006


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



More information about the talk mailing list