View Single Post
Old 12-14-2012, 10:22 PM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,055
Quote:
Originally Posted by Webmaster Advertising View Post
Im still screwing something up

http://www.pixelsquaredesigns.com/words/

Has a bunch of spaces between the words, except for the last 4 lines now :/
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.
__________________
All cookies cleared!

Last edited by sarettah; 12-14-2012 at 10:28 PM..
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote