Key array, value array => single assoc. array

From: Date: Fri, 17 Dec 1999 22:50:55 +0000
Subject: Key array, value array => single assoc. array
Groups: php.version4 
Request: Send a blank email to php-version4+get-8111@lists.php.net to get a copy of this message
I was going to post this on php3 list, but maybe it's apropo to the array traversal issue. I have an associative array (of meta-tag information from a file), and I want both the keys and the values in a form, to allow editing of tags like: '<meta name="$key" content="$value">' That part's easy, using "while (list($key,$value) = each ($metadata)) ..." However, I haven't come up with a better way than this: <input name="keys[]" value="<? echo $key?>"> <input name="values[]" value="<?echo $value>"> which gives me back two arrays, $keys and $values on submission. I can use a for loop to put them back into one associative array, but it seems there must be a better way - else why use an associative array at all? I'm just not thinking on the right wavelength. G

« previous php.version4 (#8111) next »