Mixing Arrays
| From: | Webmaster | Date: | Tue, 15 Apr 2003 10:37:55 +0000 |
| Subject: | Mixing Arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-143901@lists.php.net to get a copy of this message | ||
Anybody out there that can help me with this one?
Have the following form posting arrays to a text file :
<form method="post" action="prod.php">
<input type="text" name="prodid[ ]" size="7">
<input type="text" name="proddes[ ]" size="35">
<input type="text" name="prodid[ ]" size="7">
<input type="text" name="proddes[ ]" size="35">
<input type="text" name="prodid[ ]" size="7">
<input type="text" name="proddes[ ]" size="35"> ... and so
on
<input type="submit" value="Submit">
prodid is the Product ID and
proddes is the Product Description
On prod.php I have :
$data1 = join("%", $prodid);
$data2 = join("%", $proddes);
$main_data = "$data1" . "$data2";
$fh = fopen("products.txt", "w");
if (!$fh) {
die("<br>Failed to open file");
}
fwrite($fh, "$main_data");
fclose($fh);
this generates the output in the textfile as:
1%2%3%Product One Description%Product Two Description%Product Three
Description
Question is - how do I get the script to write to the text file so that I
have a result that looks like this:
1%Product One Description%2%Product Two Description%3%Product Three
Description
Any help will be appreciated! - Thanx
August Kupke