I can't for the world of me figure out how to decide in what order the form entries should be written to the file.
Here is the trick i've seen... for instance if you play with the Microsoft Address Book.. you can save your addresses as a Comma Seperated Text File... here is in general how it is done.
the first line of the file you save has the order of the form items... so the order is irrelevant... the procedure for saving retrieving is
0) in php get form data you want to store into an array
$data_to_store = array( 'name'=>'ednark', 'address' => 'home', 'phone'=>'8675309' )
1) open your data file
2) read in first line
BEGIN_FILE
name, address, phone
END_FILE
3) seperate line into form entry names
$order = array( 'name', 'address', 'phone )
4) in the order you pull the first line items out write a new line to the file...
$newline = ''
foreach ( $order as $key ) {
$new_line = $data_to_store[$key] .', ';
}
write_to_file($newline);
5) so you end up with
BEGIN_FILE
name, address, phone
ednark, home, 8675309
END_FILE
So in this manner... the storage order of each file is dictated by the storage file itself... and the code which uses is general enough to be used accross several projects..
hope this helps