Jump to content

Check if a string is true.


hoangthi

Recommended Posts

// 1 or more numbers following
if ( preg_match('~^A[0-9]+$~',$string) ) {
// true
}

// 2 or more numbers following
if ( preg_match('~^A[0-9]{2,}$~',$string) ) {
// true
}

// exactly 7 numbers following
if ( preg_match('~^A[0-9]{7}$~',$string) ) {
// true
}

// between 5 and 7 numbers following
if ( preg_match('~^A[0-9]{5,7}$~',$string) ) {
// true
}

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.