Jump to content

Archived

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

deadonarrival

Really simple question

Recommended Posts

Really simple question here - I just don't remember exacty how to do it. =P

Anyway I have a string $username and I want to do a quick error check if the username contains a _ or a -

Could anyone give me this line of code please? I thought of using ereg but I'm not too confident in using the function.

Thanks
~DeadOnArrival

Share this post


Link to post
Share on other sites
[!--quoteo(post=364484:date=Apr 13 2006, 01:07 PM:name=deadonarrival)--][div class=\'quotetop\']QUOTE(deadonarrival @ Apr 13 2006, 01:07 PM) [snapback]364484[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Really simple question here - I just don't remember exacty how to do it. =P
[/quote]

[code]
if (preg_match('|[-_]|', $username))
  // it contains either a - or a _
else
  // it doesn't contain either
[/code]

Share this post


Link to post
Share on other sites

×

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.