Home > Backend Development > PHP Tutorial > PHP reads csc file and outputs_PHP tutorial

PHP reads csc file and outputs_PHP tutorial

WBOY
Release: 2016-07-13 09:53:12
Original
1096 people have browsed it

php reads the csc file and outputs it

This article will share with you the method of php reading the csc file and outputting it. The first method uses the fgetcsv function, and the second method uses Here is the fopen function, friends in need can refer to it.

Method 1:

 ?

1

2

3

4

5

6

7

8

9

10

11

12

$row = 0;

$j = 1; // Linea por la que quieres empezar

$file = "name.txt"; //Nombre del fichero

if (($handle = fopen($file, "r")) !== FALSE) {

while (($data = fgetcsv($handle, ",")) !== FALSE) {

print_r($data);

$j ;

$row ;

}

}

?>

1

2

3

1

2

3

4

$fh = fopen("contacts.csv", "r");

while($line = fgetcsv($fh, 1000, ",")) {

echo "Contact: {$line[1]}";

}

4

5

6

8 9 10 11 12
$row = 0;
<🎜>$j = 1; // Linea por la que quieres empezar<🎜> <🎜>$file = "name.txt"; //Nombre del fichero<🎜> <🎜>if (($handle = fopen($file, "r")) !== FALSE) {<🎜> <🎜>while (($data = fgetcsv($handle, ",")) !== FALSE) {<🎜> <🎜>print_r($data);<🎜> <🎜>$j ;<🎜> <🎜>$row ;<🎜> <🎜>}<🎜> <🎜>}<🎜> <🎜>?>
Method 2:  ?
1 2 3 4 $fh = fopen("contacts.csv", "r"); while($line = fgetcsv($fh, 1000, ",")) { echo "Contact: {$line[1]}"; }
The above is the entire content of this article, I hope you all like it. http://www.bkjia.com/PHPjc/1003830.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1003830.htmlTechArticlephp reads csc files and outputs. This article will share with you the method of php reading csc files and outputting. The first method uses the fgetcsv function, and the second method uses the fopen function. Friends who need it...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template