I get a string from a db, then I remove all the HTML tags, carriage returns and newlines, before I put it in a csv. Only thing is I cant remove the excess white space from between the strings, any ideas?
Thanks,
Joe
I get a string from a db, then I remove all the HTML tags, carriage returns and newlines, before I put it in a csv. Only thing is I cant remove the excess white space from between the strings, any ideas?
Thanks,
Joe
$str = str_replace(' ','',$str);
Or, replace with underscore, & nbsp; etc etc.
Not sure exactly what you want but here are two situations
If you just are dealing with excess whitespace on the beginning or end of the string you can use trim() ltrim() or rtrim() to remove that.
If you are dealing with extra spaces within a string consider a preg_replace of multiple whitespaces " "* with a single whitespace " "
$foo = preg_replace( '/\s+/', ' ', $foo );
Thanks genio!