-1

Is there a function in php that lets you read a csv and return a string as it is. I am aware of functions like fgetcsv etc that reads the csv and returns an array. But I was wondering if there is a way to get the full string as it is.

Kiran Dash
  • 4,816
  • 12
  • 53
  • 84

2 Answers2

1

You must use the file_get_contents function

$data = file_get_contents('http://absoluteUrl');

or

$data = file_get_contents('local url');

Instead, to obtain an array of csv's lines use the file function.

user2342558
  • 5,567
  • 5
  • 33
  • 54
1

You could use the file function:

$file = file("somefile.csv")

The you have every line in the variable file:

$file[0] = Firstline, aso.
Nilse
  • 140
  • 9