I have been working on a requirement (in PHP), where I had stuck with the below.
I need to search for the numbers between 6800 to 6899. How can I search starts with the string ‘68’. So that I will get all the numbers in that range.
Now, I have an idea like:
if ($Model== 'Jazz6800i') return true;
if ($Model== 'Jazz6801i') return true;
......
if ($Model== 'Jazz6899i') return true;
Do we have any alternate in PHP instead of writing hell lot of code, to search starting with 68?
Use regexp:
function isInCorrectRange($item)
{
return preg_match('/Jazz68[0-9][0-9]i/', $item);
}
$result = isInCorrectRange('Jazz6801i');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With