SchweppesAle Posted January 16, 2010 Share Posted January 16, 2010 is there anyway to return the position of every "\n" in a string? Link to comment https://forums.phpfreaks.com/topic/188698-finding-substring-position/ Share on other sites More sharing options...
JAY6390 Posted January 16, 2010 Share Posted January 16, 2010 for what purppose? Link to comment https://forums.phpfreaks.com/topic/188698-finding-substring-position/#findComment-996145 Share on other sites More sharing options...
SchweppesAle Posted January 16, 2010 Author Share Posted January 16, 2010 for what purppose? http://www.phpfreaks.com/forums/index.php/topic,284320.msg1348337.html#msg1348337 I'm trying to use substr in combination with file_get_contents in order to parse an enormous csv file. I had tried the following code already with little success: $file = 'nameOfFile.csv'; $handle = fopen($file, 'r'); $endOfRow = FALSE; $offset = 0; $maxLength = 2; $row = 1; while (($data = fgetcsv(fopen($file, "r"), 0, ",", '"'))) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } Link to comment https://forums.phpfreaks.com/topic/188698-finding-substring-position/#findComment-996174 Share on other sites More sharing options...
SchweppesAle Posted January 16, 2010 Author Share Posted January 16, 2010 nvm, that was pretty easy echo strpos(file_get_contents($file), "\n", 141); Link to comment https://forums.phpfreaks.com/topic/188698-finding-substring-position/#findComment-996214 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.