file() function

Using the <pre> tag, we show the code below which produces the results shown below the code. The code you see below is also run "behind the scenes" in PHP

The file() function reads an entire file into an array. Each line of the file
is a separate element of the array, starting at zero.

^Nelson, Bill^WebDeveloper^54^ Male
^Nelson, Rita^Stocking^47^ Female
^Nelson, Caroline^Student^17^ Female
^Nelson, Sarah^Student^15^ Female
^Nelson, Joel^Construction^24^ Male
^Nelson, Rachel^Singer^26^ Female


/** open file and print each line

$myFile = file("data.txt")

for($index = 0; $index < count($myFile); $index++)
        print ($myFile[$index]);


Back to Bill's PHP