number of 5 digits?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

number of 5 digits?

Post by ddragas »

how can I check if variable is number of 5 digits?
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

if its an integer, you could use is_int() followed by strlen()
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

echo (preg_match('#^\d{5}$#',$value)?'yes':'no');
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Feyd, I truely believe you have the ablility to do anything with a preg_* statement.
Can you write me one that turns water into lager for me?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

[offtopic]

Code: Select all

$now_with_beer = preg_replace('#\bwater\b#i',"[i]your favorite fermented beverage 'ere[/i]",$without_beer);
:P
Post Reply