You were on the right track, but there were some problems with the code you posted. First, there was no closing parenthesis for the while loop. Secondly, $ line_of_text will be overwritten with each iteration of the loop, which is fixed by changing in loop = to a. =. Third, you explode the literal characters \ n ', not the actual newline; in PHP, single quotes will indicate alphabetic characters, but double quotes will actually interpret escaped characters and variables.
<?php $file = fopen("members.txt", "r"); $i = 0; while (!feof($file)) { $line_of_text .= fgets($file); } $members = explode("\n", $line_of_text); fclose($file); print_r($members); ?>
Nick Andren May 30 '11 at 5:24 a.m. 2011-05-30 05:24
source share