I would recommend use strpos() function rather than combination of substr() and strlen() in your case:
$model_no1 = 'KK71458';
$model_no2 = 'IX41';
$models = array('KK61', 'KK71', 'KK81', 'IX', 'IJ');
$result1 = check_model($model_no1, $models);
$result2 = check_model($model_no2, $models);
function check_model($model_no, array $models) {
foreach ($models as $needle) {
if (0 === strpos($model_no, $needle))
return true;
}
return false;
}
I wrote the simple test for checking string comparison performance by strpos(), strstr() and substr()+strlen(). Here is results:
Test name Repeats Result Performance
strpos 10000 0.167221 sec +0.00%
strstr 10000 0.169299 sec -1.24%
substr+strlen 10000 0.207363 sec -24.01%
As you see strpos() has best performance results.