It is necessary to compare the $com variable, which takes only positive integer values (in essence, this is a counter). Must end with 1, but not 11. That is, if $com=1 returns true , if $com=11 returns false , but when $com=21 returns true, I think I am correct, but I’m missing something.
preg_match('/[^1]*1$/',$com);