Re: array_push but with key, value pairs
| From: | Joseph Blythe | Date: | Tue, 17 Apr 2001 06:07:27 +0000 |
| Subject: | Re: array_push but with key, value pairs | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-48899@lists.php.net to get a copy of this message | ||
Peter Houchin wrote:
what about if you assign the key to = the id (if in a data base)? maybe like while (list ($key, $val) = each ($id)) { if ( $key != "Submit" ) {0 => value1 1 => value2 2 => value 3 4 = value4 But I want to create: keyname1 => value1 keyname2 => value2 keyname3 => value3 keyname4 => value4 Does anyone understand what I am on about? Regards, Josepharray_push($input, $val); } }I am not using a database for this part as I am just collecting the data to validate. I really want to know how to create a new array in a while loop, which contains the key and value pairs of the array passed to each. So lets say the above code would output: