-
- $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
- ?>
- < !--
- A,a@example.com,11111
- B,b@example.com,22222
- -->
Copy code
Example 2, fgetcsv reads a csv file
-
-
- $fh = fopen("./demoCSV.csv", "r");
- while (list($name, $email, $phone) = fgetcsv ($fh, 1024, ",")) {
- echo "
$name ($email) Tel. $phone ";
- } //edit by bbs.it-home.org
- ? >
-
Copy code
Example 3, fopen reads a csv file
-
-
- $file = "./demoCSV.csv";
- $fh = fopen($file, "rt");
- $userdata = fread($fh, filesize($file));
- fclose($fh);
echo $userdata;
- ?>
-
Copy code
|