faqts : Computers : Programming : Languages : PHP : Function Libraries : Arrays

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

50 of 61 people (82%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How do I read a file into an array?
How do I read a file into an array?

Mar 3rd, 2006 10:47
IceCold Fire, Joachim Klinkhammer, Tam bouma, Onno Benschop,


$myarray = file("/path/to/somefile");
$myarray is now an array. each line in the file, is now a cell in the 
array
using the explode command
$file="whatever.text"; // turns the file into a string
$myarry = explode("|", $file); // breaks the file up into an array 
with each cell created at | (or whatever else you want to create the 
split at)