>>>>> "S" == "stas"  <[EMAIL PROTECTED]> writes:

 > 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"; 
 > }

If you're not bothered about the initial values in the hash, you
can do it with array_flip() like this:

<?php
  $fields = explode( ',', 'firstname,lastname,city,state,phone' );
  $form   = array_flip( $fields );
?>

You'll end up with a hash like this:

  $form = array(
                 'firstname' => 0,
                 'lastname'  => 1,
                 'city'      => 2,
                 'state'     => 3,
                 'phone'     => 4
               );




-- 
Robin Vickery...............................................
Planet-Three,  3A West Point, Warple Way, London, W3 0RG, UK
Email: [EMAIL PROTECTED]     Phone: +44 (0)870 729 5444

-- 
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