filmov
tv
How do I check if a string contains a specific word in php language

Показать описание
You can use the strpos() function which is used to find the occurrence of one string inside another one:
strpos ( string $haystack , string $needle [, int $offset = 0 ] ) : int|false
haystack
The string to search in.
needle
Prior to PHP 8.0.0, if needle is not a string, it is converted to an integer and applied as the ordinal value of a character. This behavior is deprecated as of PHP 7.3.0, and relying on it is highly discouraged. Depending on the intended behavior, the needle should either be explicitly cast to string, or an explicit call to chr() should be performed.
offset
If specified, search will start this number of characters counted from the beginning of the string. If the offset is negative, the search will start this number of characters counted from the end of the string.
strpos ( string $haystack , string $needle [, int $offset = 0 ] ) : int|false
haystack
The string to search in.
needle
Prior to PHP 8.0.0, if needle is not a string, it is converted to an integer and applied as the ordinal value of a character. This behavior is deprecated as of PHP 7.3.0, and relying on it is highly discouraged. Depending on the intended behavior, the needle should either be explicitly cast to string, or an explicit call to chr() should be performed.
offset
If specified, search will start this number of characters counted from the beginning of the string. If the offset is negative, the search will start this number of characters counted from the end of the string.