What PHP function can be used to load data from a file into an array?
To load data from a file into an array in PHP, you can use the `file()` function. This function reads a file into an array where each element of the array represents a line of the file. This makes it easy to access and manipulate the data within the file.
// Load data from a file into an array
$dataArray = file('data.txt');
// Loop through the array and display each line
foreach ($dataArray as $line) {
echo $line . "<br>";
}
Keywords
Related Questions
- How can PHP functions be used to read and manipulate data from a text file in a secure manner?
- What are some potential reasons why a program may not be inserting data into a database table as expected?
- What are some best practices for displaying a calendar with PHP, including handling date calculations and formatting?