sdhunter Posted March 14, 2009 Share Posted March 14, 2009 Hi guys, im new here and could do with some help. I have a text file with items in it that i need to load into an array items.txt pens pencils paints Im loading up my txt file with this code, but its putting all 3 lines from the text file in the first slot on the array as [pens pencils paints]. I would like it to put them into 3 seperate slots [pens],[pencils],[paints]. Hope you can help. thanks! $myFile = "items.txt"; $fh = fopen($myFile, 'r'); $theData = fread($fh, filesize($myFile)); fclose($fh); $items = array($theData); echo $items[0]; Link to comment https://forums.phpfreaks.com/topic/149440-solved-loading-txt-file-into-an-array/ Share on other sites More sharing options...
ratcateme Posted March 14, 2009 Share Posted March 14, 2009 look at file it should do what you want Scott. Link to comment https://forums.phpfreaks.com/topic/149440-solved-loading-txt-file-into-an-array/#findComment-784851 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.