Re: [PHP] how do i get assosciative name in foreach

2003-08-14 Thread Philip Olson
$arr = array('key' => 'value'); foreach ($arr as $k => $v) { echo "$k is the name/key, $v is the value"; } Regards, Philip On 8 Aug 2003, Dan Anderson wrote: > I want to send an assosciative array to a foreach loop. Is there any > way to get the name? > > For instance, now I have: > >

Re: [PHP] how do i get assosciative name in foreach

2003-08-10 Thread CPT John W. Holmes
From: "Dan Anderson" <[EMAIL PROTECTED]> > I want to do: > > > $array['element1'] = 'element1'; > $array['element2'] = 'element2'; > > foreach ($array as $element) > { > // assuming get_assoc gets the assosciative name > if (get_assoc($element) == 'element1') > {get_assoc($element) do_s

[PHP] how do i get assosciative name in foreach

2003-08-10 Thread Dan Anderson
I want to send an assosciative array to a foreach loop. Is there any way to get the name? For instance, now I have: I want to do: Is what I want possible? Thanks in advance, Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php