<html>
<head>
<title>fgetcsv_reg_0.php</title>
</head>

<body>
<h1>fgetcsv_reg_0.php</h1>
????????<br />
?fgetcsv( )????????????????????? <br />

<a href="http://yossy.iimp.jp/wp/?p=56">?????????????????????</a>

fgetcsv??????<br />
??????????<br /><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;
}
?>

<?php
$row = 1;
$handle = fopen("fgetcsv_reg_0.txt", "r");
while (($data = fgetcsv_reg($handle)) !== false) {
$_enc_to=mb_internal_encoding();
$_enc_from=mb_detect_order();
$num = count($data);
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "/";
}
echo "<br />\n";
}
fclose($handle);
?>

</body>
</html>