Answers for "php read file into array"

PHP
3

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 read text file into array

//php read a text file into an array
//each item in the array is a line in the text file
//file.txt looks like this:
//hello
//testing
//text
//end file.txt (the file doesn't include the // marks
$file = file("http://example.com/file/file.txt");
echo $file[0]; //prints hello
echo $file[1]; //prints testing
echo $file[2]; //prints text
Posted by: Guest on August-02-2021
0

read file and convert each line in array php

$lines = file($filename, FILE_IGNORE_NEW_LINES);
Posted by: Guest on October-06-2020

Code answers related to "php read file into array"

Browse Popular Code Answers by Language