Finding substrings and removing unwanted whitespace are everyday tasks. PHP provides purpose-built functions for both.
strpos()returns the position (0-based) of the first occurrence, orfalseif not found.str_contains()(PHP 8+) returns a boolean — cleaner for simple checks.trim()strips whitespace from both ends;ltrim()/rtrim()strip from the left or right only.
Always use strict comparison (!== false) with strpos() because a match at position 0 is falsy.