Quote:
Originally Posted by sarettah
You have something other than a space in there.
So, instead of just doing the replace do a trim when you put the words together.
Here:
array_push($cwords, $curword . $word);
Change to
array_push($cwords, trim($curword) . trim($word));
or
Here:
array_push($words, strip_newlines(fgets($handle)));
change to
array_push($words, trim(strip_newlines(fgets($handle))));
Trim takes white space (not just blanks) from the beginning and end of the string.
Edited in:
A better place for it is in the strip_newlines function actually.
Changing return $str; to return trim($str); will accomplish the exact same thing with slightly less typing. It depends on how you would interpret what you want the strip_newlines function to be as to whether it is in the right place.
|
Trim worked perfectly, thanks Sarettah.
Stupid question though, if this was just a list of words typed in notepad, one word per line, how come there was a space in there, is that an issue with the server parsing the array or something notepad related?