- Code: Select all
<html>
<head><title>File Input Output</title></head>
<body>
<?php
if (!isset($_POST['submit'])){
?>
<?php
$files = file("file.txt");
?>
<form action="file_array.php" method="post">
<select name="name[]">
<?php
foreach ($files as $file ){
$file = explode(",", $file);
list($name, $address, $age) = $file;
trim($address);
?>
<option value="<?php echo $name; ?>"><?php echo $name; ?></option>
<option value="<?php echo $address; ?>"><?php echo $address; ?></option>
<?php
}
?>
</select>
<input type="submit" name="submit" value="send" />
</form>
<?php
} else {
$a=$_POST['name'];
echo $a[0];
}
?>
</body>
</html>
The code works fine but I want to have another <option value="<?php echo $address; ?>"><?php echo $address; ?></option>. The problem is if I add this code it will only add to the <option value="<?php echo $name; ?>"><?php echo $name; ?></option>. I need to separate them. Any idea is highly appreciated. Thanks.

