Jump to content

Numbers only


Woodburn2006

Recommended Posts

Just add in a logical not.

 

preg_match($regex, $string) returns a boolean.  You can think of $regex as a set of rules that a string has to follow. 

 

In this case '/^[1-2][0-9]{3}$/' means "Starts with a one or two and is followed by three digits."  If $string follows all the rules, preg_match returns true.

Link to comment
https://forums.phpfreaks.com/topic/70185-numbers-only/#findComment-352556
Share on other sites

Archived

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

×
×
  • Create New...

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.