Jump to content

Killing spaces in strings


sorenchr

Recommended Posts

Hi there, im having a bit of trouble with strings consisting of nothing else but blank spaces.

Since im using a rather large function, i've decided not to bother you with the more complex details and just make a little example that illustrates my problem.

 

Im looking for a function that will target and delete strings containing nothing more but spaces (1 or more), i've tried the following:

 

$string = " ";
str_replace(' ', '', $string);

if(empty($string)) {

echo "empty!";

}

else {

echo "spacy, i say";

}

 

Im absolutely out of ideas of what to do, since this obviously doesn't work. Anybody got a solution?

Link to comment
https://forums.phpfreaks.com/topic/118844-killing-spaces-in-strings/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.