-
-
$users = file("./demoCSV.csv");
- foreach ($users as $user) {
- list($name, $email, $phone) = explode(",", $user);
- echo "
$name ($email) Tel. $phone ";
- } //edit by bbs.it-home.org
- ?>
复制代码
例2,fgetcsv读取一个csv文件
-
-
$fh = fopen("./demoCSV.csv", "r");
- while (list($name, $email, $phone) = fgetcsv($fh, 1024, ",")) {
- echo "
$name ($email) Tel. $phone ";
- } //edit by bbs.it-home.org
- ?>
-
复制代码
例3,fopen读取一个csv文件
-
-
$file = "./demoCSV.csv";
- $fh = fopen($file, "rt");
- $userdata = fread($fh, filesize($file));
- fclose($fh);
echo $userdata;
- ?>
-
复制代码
|