Hi Reader's,
Welcome to FindNerd, today we are going to discuss how to reads a file into an array ?
If you want to read a file into an array then, you should use file() function.This function reads a file into an array.
syntax of file() function
file(path,include_path,context);
So there are 3 main parameter of above syntax
1-path is a required parameter.
2-include_path and context both are optional parameter
you can see below example:
<?php
//here call file() and print your file
print_r(file("file.txt"));
?>
The output of the code above will be:
Array ( [0] => Hi all welcome to findnerd )
0 Comment(s)