■PHPでCSVファイルの読み込み方
(1)データファイルの用意
・ファイル名 : data.csv
・ファイルの内容
1,ハンバーガー,500円
(2)PHPファイル
---------------------------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="ja">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=Shift_Jis">
<title>CSVファイルの読み込み</title>
</head>
<body>
<p>
<?php
$opencsvfile = file_get_contents('data.csv');
echo $opencsvfile;
?>
</body>
</html>
---------------------------------------------------------------------------------------------
~file_get_contents関数~
(1)データファイルの用意
・ファイル名 : data.csv
・ファイルの内容
1,ハンバーガー,500円
(2)PHPファイル
---------------------------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="ja">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=Shift_Jis">
<title>CSVファイルの読み込み</title>
</head>
<body>
<p>
<?php
$opencsvfile = file_get_contents('data.csv');
echo $opencsvfile;
?>
</body>
</html>
---------------------------------------------------------------------------------------------