Re: Quickly verifying single word.
| From: | Shawn McKenzie | Date: | Thu, 05 Jun 2008 00:02:39 +0000 |
| Subject: | Re: Quickly verifying single word. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-275037@lists.php.net to get a copy of this message | ||
Shawn McKenzie wrote:
Tyson Vanover wrote:Second one doesn't work for some reason. No time now to test, will later. -ShawnI 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.if (strpos($string, ' ') === false) { //may not work for tabs, newlines etcecho 'No spaces!';} if (preg_match('/[\s]*/', $string) === false) {echo 'No spaces!';} -Shawn