By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,262 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,262 IT Pros & Developers. It's quick & easy.

space in username

exoskeleton
100+
P: 104
hi guys...please help how to test if username contains spaces!

for example: "ric hard" = will be invalid!

supposed to be "richard"

TIA... :)
Apr 16 '07 #1
Share this Question
Share on Google+
6 Replies


exoskeleton
100+
P: 104
anyone please help...i just wanna up this question! thank you
Apr 18 '07 #2

P: 13
hi,

hope this piece of code helps, change to your requirement :

Expand|Select|Wrap|Line Numbers
  1. $mystring = 'ric hard';
  2. $findme   = ' ';
  3. $pos = strpos($mystring, $findme);
  4. // Note our use of ===.  Simply == would not work as expected
  5. // because the position of 'a' was the 0th (first) character.
  6. if ($pos === false) {
  7.     echo "The string '$findme' was not found in the string '$mystring'";
  8. } else {
  9.     echo "The string '$findme' was found in the string '$mystring'";
  10.     echo " and exists at position $pos";
  11. }
  12.  
this code help to find the character existence...

Source : www.php.net
Apr 18 '07 #3

100+
P: 136
u can use -

[PHP] preg_match('/\s/', $UserName)[/PHP]

it will return FALSE if no space found.

susen
Apr 18 '07 #4

exoskeleton
100+
P: 104
u can use -

[PHP] preg_match('/\s/', $UserName)[/PHP]

it will return FALSE if no space found.

susen
hi sir devsusen...how can i add more characters in preg_match to find?

thank you
Apr 19 '07 #5

exoskeleton
100+
P: 104
hi,

hope this piece of code helps, change to your requirement :

this code help to find the character existence...

Source : www.php.net
thank you sir Deejam...
Apr 19 '07 #6

P: 13
you can add character between the quotes...


[PHP]preg_match('abcdef', $UserName)[/PHP]


Download the php manual, which helps alot

http://www.php.net/download-docs.php
Apr 19 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.