Jump to content


Photo

Really simple question


  • Please log in to reply
2 replies to this topic

#1 deadonarrival

deadonarrival
  • Members
  • PipPipPip
  • Advanced Member
  • 284 posts

Posted 13 April 2006 - 05:07 PM

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
DO {
$this->time_warp("Jump to the left","Step to the right","Bend knees in time");
} WHILE (2>1)

Warning: The above post may not make a lot of sense, and the sentence structure will suck. I tend to ramble a lot. Sorry ;-)

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 13 April 2006 - 05:17 PM

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

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

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 deadonarrival

deadonarrival
  • Members
  • PipPipPip
  • Advanced Member
  • 284 posts

Posted 13 April 2006 - 08:36 PM

Perfect thanks a lot
DO {
$this->time_warp("Jump to the left","Step to the right","Bend knees in time");
} WHILE (2>1)

Warning: The above post may not make a lot of sense, and the sentence structure will suck. I tend to ramble a lot. Sorry ;-)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users