I would like to remove last character from a word. I have a file with the words:
hello.
world
welcome.
home..
how.
are.
you
any
thing.
else.
I am trying to remove the .
from the end of each line.
For some reason my code removes the dot only from the last world else
but leaves the rest as is.
Here is my code:
$words = file('words.txt');
foreach($words as $word)
{
echo substr($word, 0, -1);
echo "<br />";
}
Does any one know how can i fix this?