Thanks, I know that, but I don't want to type out assignments manually, as
my list of my form values will grow. However, I solved very simply like
this:

$form_val_list =
"firstname,lastname,address,address2,city,state,zip,phone,email,resume";
$form_arr = explode (",", $form_val_list);

while (list ($key, $val) = each ($form_arr))
{
     $new_arr[ $val] = "some test value";
}

stas


----- Original Message -----
From: "Boget, Chris" <[EMAIL PROTECTED]>


> > I am trying to create an associative array dynamically.
> > Here's what I did first:
> >  $form_val_list =
> > "firstname,lastname,address,address2,city,state,zip,phone,emai
> > l,resume";
> >  $form_arr = explode (",", $form_val_list);
> >   while (list ($key, $val) = each ($form_arr))
> >   {
> >        echo "$key is $val<br>";
> >   }
> > This doesn't do the trick, as it creates a regular array with
> > values from my list, as in form_array['1'] = "firstname";
> > whereas I need form_array['firstname']
> > Is this possible without being overly complicated? Thanks.
>
> You need to assign a value to that element.  This would work:
>
> $assocArray = array();
> $assocArray[firstname] = $someVal;
> $assocArray[lastname] = $someVal;
>
> Alternately, you can do:
>
> $assocArray = array( "firstname" => $someVal, "lastname" => $someVal );
> etc.
>
> Chris
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to