ijsselg Posted February 13, 2013 Share Posted February 13, 2013 Hi, I want to read a file, and while reading I want to put the first line (before the first \n) in variable one second line in variabele two third line in variabele three. And I want to use it in html: $text = str_replace("\n","<br>",file_get_contents($file)); Anyone can help a little? Quote Link to comment https://forums.phpfreaks.com/topic/274450-read-file-and-cut-text-in-peaces/ Share on other sites More sharing options...
AyKay47 Posted February 13, 2013 Share Posted February 13, 2013 Look into using fgets and store the lines into an array. Quote Link to comment https://forums.phpfreaks.com/topic/274450-read-file-and-cut-text-in-peaces/#findComment-1412271 Share on other sites More sharing options...
ijsselg Posted February 13, 2013 Author Share Posted February 13, 2013 thanks! Quote Link to comment https://forums.phpfreaks.com/topic/274450-read-file-and-cut-text-in-peaces/#findComment-1412278 Share on other sites More sharing options...
Barand Posted February 13, 2013 Share Posted February 13, 2013 Use file - it will put the lines into an array for you Quote Link to comment https://forums.phpfreaks.com/topic/274450-read-file-and-cut-text-in-peaces/#findComment-1412342 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.