Re: Quickly verifying single word.

From: Date: Wed, 04 Jun 2008 23:10:09 +0000
Subject: Re: Quickly verifying single word.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-275034@lists.php.net to get a copy of this message
There's probably a regex solution that is most elegant, but here is one solution: if ($str == str_replace(array(' ', "\n"), '', $str)) {
    // if you get here, then $str has no spaces or newline characters
} ~Ted On 4-Jun-08, at 4:04 PM, Tyson Vanover wrote:
I need a quick way to make sure that a string is a single word with no white spaces. I would prefer that it is a command that could fit on a single line. Or at least an if block. I have a few thoughts on this but it involves things like explode(), stripslashes(), etc. --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#275034) next »