2011-07-06 9 views
0

私は送信時に私たちに電子メールを送信するサインアップフォームを持っています。複数の単語が入力されないように、推奨されるユーザー名フィールドをトリミングすることはできますか?あるいは、1つの単語を形成するために提出時にスペースを自動的に排除するのでしょうか?複数の単語のフォームフィールドを防ぐPHPのMySQL

答えて

1

あなたはあなたのケースではpreg_replace($patterns, $replacements, $string);になっているはずです、あなたが望む:

// \s+ means 1 or more whitespace characters. 
// '' means that the whitespace will be replaced by emptiness. 
// so this should return a string which replaces all whitespace with nothing 
preg_replace("#\s+#g", '', $string); 
関連する問題