1) AS stated in the comments I would use the magic of math
if(preg_match( '/^D([0-9]+)/', 'D30500', $match )){
if( $match[1] < 300000 ){ //$match[1] = '30500';
//do something
}
}
For the Regx
https://regex101.com/r/KppvPh/1
2) You could also just do substr too
$number = substr('D30500', 1 ); //= 30500
Such as this
$check = substr("D30500" ,1);
$start = substr("D000000" ,1);
$end = substr("D300000" ,1);
if( $check > $start && $check < $end ){
//bla bla ( inclusive? )
}
And if you want to get real fancy you can cast it as an int $start = intval(substr("D000000" ,1));
3) You cal also do that using array.
<?php
$from = 'D101';
$to = 'D105';
array_walk(range(substr($from,1),substr($to,1)), function ($v, $k) {
$search = 'D105';
if($v==substr($search,1)){
echo "Yes !!!";
}
});
?>
4) Updated answer.
<?php
// 2)
$from = 'ASD000';
$to = 'ASD3000';
$search = 'ASD3000';
preg_match_all('!\d+!', $from, $matches);
$from_int = $matches[0][0];
preg_match_all('!\d+!', $to, $matches);
$to_int = $matches[0][0];
preg_match_all('!\d+!', $search, $matches);
$search_int = $matches[0][0];
if( $search_int > $from_int && $search_int < $to_int ){
echo "Yes !!!";
}
?>