Data files that users submit on my site are formatted like this:
Text text text text text
text texttext text text
text text text text
text text text text text
text text text text
text text text
While developing my php script to read these files, I would explode() the file after using file_get_contents with the delimiter \n\n which would make an array from the above example.
But now that I am transitioning to a live site, and am developing the form to submit the file, this explode technique no longer works.
foreach ($_FILES['file']['tmp_name'] as $file) {
$fname = file_get_contents($file);
$rows = explode("\n\n", $fname);
//do work
}
When I echo $row[0] the entire uploaded file is returned, instead of just the first paragraph. $rows[1] is empty. Why isn’t explode working here?
try to normalize line endings: