This preg_match
will never work even though I think its the right thing.
I'm trying to check a string so that it's structured as follows
$value = US 01 02 1406034963 .JPG //I've put spaces in. The real one is below.
So:
The first part (US) is alphabets, only two characters from a-z
The second part (01) is a value 00 or 01
The third part (02) is digits 0-9 from 2 - 10 (can be 2 to 10 digits long)
The fourth part (1406034963) is a 10 digit figure, and only 10 digits
The fifth part is .jpg or .jpeg or .png. or .gif
But, my function always returns false. Can you please help?
//
function preset($value) {
if(preg_match('/^[a-z]{2}[00|01][0-9]{2,10}[0-9]{10}[.jpg|.jpeg|.png.|.gif]$/',$value)) {
return true;
} else {
return false;
}
}
$value = 'US01021406034963.JPG';
if(preset($value)) {
echo 'Yeah!';
} else {
echo 'Boo!';
}