tags: #php #string #prefix #snippet ```php # is $needle a prefix of $haystack function is_prefix(string $needle,string $haystack) : bool { $l = strlen($needle); if( $l > strlen($haystack) ) return false; return $needle === substr($haystack,0,$l); } ```