1.

How To Remove The New Line Character From The End Of A Text Line?

Answer»

If you are using fgets() to read a line from a TEXT file, you MAY want to use the CHOP() function to remove the new line character from the end of the line as shown in this PHP script:
<?php
$handle = fopen("/tmp/inputfile.txt", "r");
while ($line=fgets()) {
$line = chop($line);
# PROCESS $line here...
}
fclose($handle);
?>

If you are using fgets() to read a line from a text file, you may want to use the chop() function to remove the new line character from the end of the line as shown in this PHP script:
<?php
$handle = fopen("/tmp/inputfile.txt", "r");
while ($line=fgets()) {
$line = chop($line);
# process $line here...
}
fclose($handle);
?>



Discussion

No Comment Found