<html>
<head>
<style>
.em{
font-weight:bold;
background-color:aqua;
}
.normal{
font-weight:normal;
background-color:#ffffff;
}
</style>

<title>reg_exp004.php</title>
</head>

<body>
<h1>reg_exp004.php</h1>
????????<br />

<h3>???????</h3>
???????????<br />
??^???????????????????????^??<br />
??$????????????????????????$?<br />

<form action="reg_exp004.php" method="post">
???
<input type="text" name="f_in">
<input type="submit" value="??" />
</form>

<?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;
}
?>

<?php
//??????????????""???????
$city = "\"" .$_POST['f_in']. "\"";
echo "?" .$city. "??????";

//???????????

$fname ='reg_exp004.txt';
$data1 = @fopen($fname,'r') or exit('???????????????');
echo "<table border=\"1\" cellpadding=\"5\">\n";
echo "<tr><th>???</th><th>???</th><th>????</th><th>????</th><th>????</th></tr>\n";

while (!feof($data1)){//eof?????????
$string = fgetcsv_reg($data1);//???????????????????
if(preg_match($city,$string[1])){
$class = "\"em\"";//????[1]????????????????
}else{
$class = "\"normal\""; //????[1]??????????????????
}

echo "<tr>\n";
foreach($string as $dt){//$dt??????????
echo "<td class=" .$class. ">" .$dt. "</td>\n";
}

echo "</tr>\n";
}
echo "</table>\n";
fclose($data1);
?>
</body>
</html>

????

??,????,11:35,15:15,ANA
??,????,12:00,15:30,JAL
??,??,11:50,16:25,ANA
??,??,12:20,17:15,AF
??,???????,10:35,15:05,ANA
??,???????,10:25,14:15,ANA
??,???????,12:20,16:35,LH
??,????,11:10,14:25,BA
??,??,21:55,4:25,JAL
??,????,12:05,16:00,ANA
??,???,12:00,16:40,JAL
??,???,13:05,19:00,AL
??,???????,14:15,18:30,KLM