<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>
<h2>BT_db_test01.php</h2>
<h3>?????????????</h3>

<form action = "BT_db_test01.php" method = "post">
<p>
????????????????????????????????<br />
??????
<input name="f_in" type="radio" value="0">????????????
<input name="f_in" type="radio" value="1">??????????
<input name="f_in" type="radio" value="2">???????????
</p>
?????????????????????<br />
???????????????????????????????????????????????<br />
??????????????????????????????????????<br />
??????????????????????????????????????<br />

<p>
??????????
<input type="text" name='f_in1'>
<input type="submit" name="Submit" value="??">?
</p>
</form>

<?php
//*********?????????? ***************//
$f_in = $_POST['f_in'];
//*********switch????????????***********//
switch($f_in){
case 0;
echo "<h3>????????</h3>";
$city_mae = "";//????????
$city_ato = "";//????????
break;
case 1;
echo "<h3>?????????</h3>";
$city_mae = "^";
break;
case 2;
echo "<h3>?????????</h3>";
$city_ato = "$";
break;

}
?>

 

<?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
//??????????????""???????
$city1 = "\"" .$city_mae.$_POST['f_in1'].$city_ato. "\"";//??
echo "????<br />";
echo "??" .$_POST['f_in1']. "??????????<br />";
echo "??" .$city_mae. "???????????<br />";
echo "??" .$city_ato. "???????????<br />";
echo "??" .$city1."????????";

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

$fname ='db_test2.txt';
$data1 = @fopen($fname,'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 (!feof($data1)){//eof?????????
$string = fgetcsv_reg($data1);//???????????????????
if(preg_match($city1,$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>

????

??,??????????,?????????????,1,????,??
??,????,?????????????,2,??11????,????
??,?????,?????????????,3,????????JR?,?????
??,????,?????????????,4,????????????,????
??,????????,?????????????,5,????????JR?,????????
??,?????,?????????????,6,????????JR?,?????
??,????,?????????????,9,????????JR?,????
??,????,?????????????,10,????????JR?,????
??,????,?????????????,11,????????JR?,????
??,??????,?????????????,12,????????JR?,??????
??,???,?????????????,13,????????JR?,???
??,????,?????????????,1,????????JR?,????
??,?????,?????????????,2,????????JR?,?????
??,???????,?????????????,3,????????JR?,???????
??,?????,?????????????,4,????????JR?,?????
??,???????????,?????????????,5,????????JR?,???????????
??,????????????,?????????????,6,????????JR?,????????????
??,?????,?????????????,9,????????JR?,?????
??,?????,?????????????,10,????????JR?,?????
??,????,?????????????,11,????????JR?,??
??,????,?????????????,12,????????????,??
??,?????,?????????????,13,????????????,??
??,????,?????????????,1,????????????,??
??,????,?????????????,2,????????????,??
??,??????,?????????????,3,????????????,??
??,??????,?????????????,4,????????????,??
??,??????,?????????????,5,????????????,??
??,????,?????????????,6,????????????,??
??,????,?????????????,9,????????????,??
??,????,?????????????,10,????????????,??
???,?????,?????????????,11,????????????,??
???,?????,?????????????,12,????????????,??
???,???????,?????????????,13,????????????,??
???,?????????,?????????????,1,????????????,??
???,???????,?????????????,2,????????????,??
???,?????,?????????????,3,????????????,??
???,?????,?????????????,4,????????????,??
???,??????,?????????????,5,????????????,??
???,??????,?????????????,6,????????????,??
???,??????,?????????????,9,????????????,??
???,???????,?????????????,10,????????????,??
???,?????,?????????????,11,????????????,??
???,?????,?????????????,12,????????????,?????
???,??????,?????????????,13,????????????,??????
???,??????,?????????????,1,????????????,??????
???,??????,?????????????,2,????????????,??????
???,???????,?????????????,3,????????????,???????
???,?????,?????????????,4,????????????,?????
??,????,?????????????,5,????????????,????
??,????,?????????????,6,????????????,????
??,????,?????????????,9,????????????,????
??,????,?????????????,10,????????????,????
??,?????,?????????????,11,????????????,?????
??,????,?????????????,12,????????????,????
??,??????,?????????????,13,????????????,??????
??,??????,?????????????,1,????????????,??????
??,??????,?????????????,2,????????????,??????
??,????,?????????????,3,????????????,????
??,????,?????????????,4,????????????,????
??,?????,?????????????,5,????????????,?????
???,??????,?????????????,6,????????????,??????
???,??????,?????????????,9,????????????,??????
???,????,?????????????,10,????????????,????
???,??????,?????????????,11,????????????,??????
???,??????,?????????????,12,????????????,??????
???,???????,?????????????,13,????????????,???????
??,????,?????????????,1,????????????,????
??,??????,?????????????,2,????????????,??????
??,???????,?????????????,3,????????????,???????
??,?????????,?????????????,4,????????????,?????????
??,?????,?????????????,5,????????????,?????
??,?????,?????????????,6,????????????,?????
????,??????,?????????????,9,????????????,????
????,??????,?????????????,10,????????????,????
????,??????,?????????????,11,????????????,????
????,??????,?????????????,12,????????????,????
????,??????,?????????????,13,????????????,????
????,??????,?????????????,1,????????????,????
???,?????,?????????????,2,????????????,?????
???,????,?????????????,3,????????????,????
???,?????,?????????????,4,????????????,?????
???,?????,?????????????,5,????????????,?????
???,????????????,?????????????,6,????????????,????????????
???,?????,?????????????,9,????????????,?????