01-01-2010, 05:05 AM
|
#2 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
I'm not quite sure why you're attempting to explode on a delimiter that doesn't exist. That just puts the same string that's already held in $line_of_text into the 0 index of an array. You could omit that and gain the same result in less code;
What you may want to do is use file() as opposed to the method you've employed. It reads files into an array, which you can then work off of.
php Code:
header( "Content-type: text/plain" ); // FILE_IGNORE_NEW_LINES only removes \n, not \r for some reason...$lines = file( __FILE__, FILE_IGNORE_NEW_LINES ); print_r( $lines ); foreach ( $lines as $line ) { // So you have to trim if you're on Windoze. $line = trim( $line ); if ( empty( $line ) ) continue; echo $line, PHP_EOL; }
You can drop the above into its own file and run it to see how it works. Then modify and incorporate as you see fit. ;)
|
|
|
|