Answers for "php read file split lines"

PHP
5

php read file line by line

$handle = fopen("inputfile.txt", "r");
if ($handle) {
    while (($line = fgets($handle)) !== false) {
        // process the line read.
    }

    fclose($handle);
} else {
    // error opening the file.
}
Posted by: Guest on May-22-2020
0

php split large text on line breaks into array

#1
$arr=explode("\n",$text);

#2
$arr=explode("<br>",nl2br($text));
Posted by: Guest on April-21-2021

Browse Popular Code Answers by Language