How to use Filesystem fgetcsv in PHP

In this article I am going to explain about fgetcsv function in PHP.
  • 1246

PHP fgetcsv() function

The filesystem fgetcsv function is used to parses a line from an open file, checking for CSV fields and returns an array containing the fields read.

Syntax of fgetcsv function

fgetcsv(filename, length, separator, enclosure)

Parameters in fgetcsv function

It have four parameter:

Parameter Description
file It specifies the open file to check.
length It specifies a maximum length of a line.
separtor It is character that specifies that the field separator.
enclouser It is a character that specifies the field enclosure character.

Example of filesystem fgetcsv function

<html>

<body>
 

<?php

$file = fopen("C:\wamp\www\Dinesh\PhpIntro.txt","r");

print_r(fgetcsv($file));

fclose($file);

?>
 

</body>
</html>


Output:

fgetcsv function.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.