I am trying to read data from a.csv file to open it on a web page as text.
This is the first time I do this, and I have an unpleasant little problem.
My. The CSV file (which opens by default by Excel) has several lines, and I read it all as one long line.
like this:
$contents = file_get_contents("files/data.csv");
In this example file I made, there are 2 lines.
Paul Blueberryroad 85 us Flashlight, bag November 20, 2008, 16:39
Hellen Blueberryroad 85 us lens13mm, flashlight, bag, ExtraBatteries November 20, 2008, 16:41:32
But the line read by PHP is this:
Paul, Blueberryroad 85, us, flashlight, bag, November 20, 2008, 4:39 pm, Hellen, Blueberryroad 85, us, 13mm lens, flashlight, bag, ExtraBatteries, November 20, 2008, 16:41:32
I share it as follows:
list($name[], $street[], $country[], $accessories[], $orderdate[]) = split(";",$contents);
, $name [] "" "". .
, $orderdate []
20 2008 , 4:39 . Hellen
, . - , , ?
: , :
, :
$fo = fopen("files/users.csv", "rb+");
while(!feof($fo)) {
$contents[] = fgetcsv($fo,0,';');
}
fclose($fo);
- , CSV 2 , 2 1 . 2 - , - 0.