<?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: