PHP read txt file

<?php
header('Content-Type: text/html; charset=utf-8');

$file = fopen("test.txt", "r");
$contArr=array();
$i=0;
// Output all lines in the text until the end of the file.
while(! feof($file)) {
    $contArr[$i]= fgets($file);//fgets() function reads a line from the file pointer
    $i++;
}
fclose($file);
$contArr=array_filter($contArr);
var_dump($contArr);

 

Effect picture:

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326437398&siteId=291194637