How to read line by line in php

后端 未结 5 1244
北荒
北荒 2021-01-06 11:21

when i try to insert each line into my oracle database i get an error stating invalid number, but if have only one line in the file it works fine.

$file = @f         


        
5条回答
  •  孤街浪徒
    2021-01-06 11:40

    Your explode() call is using 9 spaces as a separator, but your file only appears to have 5 spaces between each number. This means your $currentline be a single element array containing the original line, and not separate elements with a number in each.

    Either change the number of spaces in the explode call, or change to

    $currentLine = preg_split('/\s+/', $currentLine);
    

    which will split on any number of sequential spaces.

提交回复
热议问题