<body>
<h1>fgetcsv_reg_2.php</h1>
????????
<h3>?fgetcsv????????????????????<br />
????????????</h3>
???????????????<br />

<?php
/**
* ????????????????CSV??????????
* @param resource handle
* @param int length
* @param string delimiter
* @param string enclosure
* @return ??????????????????????FALSE??????
*/
function fgetcsv_reg (&$handle, $length = null, $d = ',', $e = '"') {
$d = preg_quote($d);
$e = preg_quote($e);
$_line = "";
while ($eof != true) {
$_line .= (empty($length) ? fgets($handle) : fgets($handle, $length));
$itemcnt = preg_match_all('/'.$e.'/', $_line, $dummy);
if ($itemcnt % 2 == 0) $eof = true;
}
$_csv_line = preg_replace('/(?:\r\n|[\r\n])?$/', $d, trim($_line));
$_csv_pattern = '/('.$e.'[^'.$e.']*(?:'.$e.$e.'[^'.$e.']*)*'.$e.'|[^'.$d.']*)'.$d.'/';
preg_match_all($_csv_pattern, $_csv_line, $_csv_matches);
$_csv_data = $_csv_matches[1];
for($_csv_i=0;$_csv_i<count($_csv_data);$_csv_i++){
$_csv_data[$_csv_i]=preg_replace('/^'.$e.'(.*)'.$e.'$/s','$1',$_csv_data[$_csv_i]);
$_csv_data[$_csv_i]=str_replace($e.$e, $e, $_csv_data[$_csv_i]);
}
return empty($_line) ? false : $_csv_data;
}
?>

<form action = "fgetcsv_reg_2.php" method = "post">
???????? <br />
<select name="f_in">
<option value = "0">??</option>
<option value = "1">??</option>
<option value = "2">??</option>
<option value = "3">??</option>
<option value = "4">??</option>
<option value = "5">??</option>
<option value = "6">???</option>
<option value = "7">???</option>
<option value = "8">???</option>
<option value = "9">??</option>
<option value = "10">??</option>
<option value = "11">???</option>
<option value = "12">??</option>
<option value = "13">????</option>
<option value = "14">???</option>
</select>
<input type="submit" value="??" />
</form>

<form action = "fgetcsv_reg_2.php" method = "post">
<p>
????????<br />
<input name="f_in" type="radio" value="1">??
<input name="f_in" type="radio" value="2">??
<input name="f_in" type="radio" value="3">??
<input name="f_in" type="radio" value="4">??
<input name="f_in" type="radio" value="5">??
<input name="f_in" type="radio" value="6">???
<input name="f_in" type="radio" value="7">??? <br />
<input name="f_in" type="radio" value="8">???
<input name="f_in" type="radio" value="9">??
<input name="f_in" type="radio" value="10">??
<input name="f_in" type="radio" value="11">???
<input name="f_in" type="radio" value="12">??
<input name="f_in" type="radio" value="13">????
<input name="f_in" type="radio" value="14">???
</p>
<p>
<input type="submit" name="Submit" value="??">
</p>
</form>

<?php
//*********?????????? ***************//
$f_in = $_POST['f_in'];
//*********switch????????????***********//
switch($f_in){
case 0;
echo "<h3>????????????</h3>";
break;
case 1;
echo "<h3>?????</h3>";
$city = "??";//??????$city???
break;
case 2;
echo "<h3>?????</h3>";
$city = "??";
break;
case 3;
echo "<h3>?????</h3>";
$city = "??";
break;
case 4;
echo "<h3>?????</h3>";
$city = "??";
break;
case 5;
echo "<h3>?????</h3>";
$city = "??";
break;
case 6;
echo "<h3>??????</h3>";
$city = "???";
break;
case 7;
echo "<h3>??????</h3>";
$city = "???";
break;
case 8;
echo "<h3>??????</h3>";
$city = "???";
break;
case 9;
echo "<h3>?????</h3>";
$city = "??";
break;
case 10;
echo "<h3>?????</h3>";
$city = "??";
break;
case 11;
echo "<h3>??????</h3>";
$city = "???";
break;
case 12;
echo "<h3>?????</h3>";
$city = "??";
break;
case 13;
echo "<h3>???????</h3>";
$city = "????";
break;
case 14;
echo "<h3>??????</h3>";
$city = "???";
break;

}

//*********????????????******************//
//*********?????????????******************//

$row = 1;
$handle = fopen("fgetcsv_reg_2.txt", "r") or exit('???????????????</body></html>');

echo "<table border=\"1\" cellpadding=\"5\">\n";
echo "<h4>??????????????</h4>\n";
echo "<tr><th>??</th><th>???</th><th>??</th><th>??</th><th>??</th><th>???</th></tr>\n";

while (($data = fgetcsv_reg($handle)) !== false) {
$_enc_to=mb_internal_encoding();
$_enc_from=mb_detect_order();
$num = count($data);
$row++;

if($data[0] == $city){
echo "<tr>\n";
foreach($data as $dt){ //$dt??????????
echo "<td>" .$dt. "</td>\n";
}
echo "</tr>\n";

}
}

echo "</table>\n";
fclose($handle);
?>

</body>