How to read line by line in php

后端 未结 5 1250
北荒
北荒 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:54

    try this :

    // Read all data in the file
    $file_all = file_get_contents('file.text') or die("unable to open file");
    // create an array with each index = a line
    $file_lines = explode(chr(13),$file_all);
    // Insert each line found
    foreach ($file_lines as $file_line) { insert($file_line); };
    

提交回复
热议问题