Hi everybody,
i got a text-file wich i want to explode.
How can i detect a new line int the text file?
text look like this:
line1line1line1line1line1line1line1
line2line2line2line2line2line2line2
line3line3line3line3line3line3line3
etc...
so there's no /n or something, just plain text
many thanx in advance
tom
detect new line in php?
Moderator: General Moderators
- potato
- Forum Contributor
- Posts: 192
- Joined: Tue Mar 16, 2004 8:30 am
- Location: my lovely trailer, next to the big tree
nope, just a text file with some text.
this is my explode code:
in the testfeed.php file i have put the whole text in $text.
My result is the whole text itself.
this is my explode code:
Code: Select all
include 'testfeed.php';
$pizza = explode("/n", $text); //opdelen
$aantal = count($pizza); //aantal pizzas tellenMy result is the whole text itself.
If I'm not mistaken, the text-file that you have will be interpreted as follows:
So you should have no trouble using the split() function:
The above will get you an array $file_lines with the lines as elements
Hope this helps.
Code: Select all
line1line1line1line1line1line1line1\n
line2line2line2line2line2line2line2\n
line3line3line3line3line3line3line3\nCode: Select all
$file_contents=file_get_contents("file.txt");
$file_lines=split("/\n",$file_contents);Hope this helps.