Optimized php check

Maybe also use array of substrings and iterate through it with a foreach loop?