I'm grabbing results from a database, and in the names table alot of the results are like this 'ONE' ' TWO ' I'm trying to remove all the space around the name, so just the name is displayed. I use this str_replace(' ','',$row['name']); But that doesn't seem to work? I'm presuming that just removes one of the whitespaces and not them all. Do I need to create a loop, and if so how? Thanks in advance
Where are the other spaces visible? In the output (source code) that the script generates, or your web browser? Note that new line characters are displayed as space too. And if you want to remove the spaces around a text, you should have a look at trim().
The whitespace was probably tabs or newlines, not spaces. trim() takes care of all whitespace. trim() PHP: wtf nico (joking)
Yeah, that's what its about. It's whitespace... Not fully understanding this trim section on the manual though..
Thanks for that nico, I enjoy waiting for your responses in the PHP forum, you're always here to help!