- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
str_contains() in PHP 8+
If we want to search a small piece of string in a big string then we can use function str_contains().
Here is str_contains() at a glance.
1. It contains the main string or the string where we are searching as the first parameter. This is called haystack.
2. The string that need to be searched is the second parameter. This is called needle.
3. This function returns boolean value - true if the string found, else false.
4. This function is case-sensitive.
5. If the search string is empty then it returns true.
6. It is introduced since version 8.
Here is an example.
We are searching string "Super" in the heredoc. The result will be true, as it is found.
$heredoc = "Math is Super easy";
$needle = "Super";
$result = str_contains($heredoc, $needle);
echo $result;
Now, we are changing the needle in small letters and search again. The result is false, because small case super is not available in the heredoc and as this function is case-sensitive.
$heredoc = "Math is Super easy";
$needle = "super";
$result = str_contains($heredoc, $needle);
echo $result;
Видео str_contains() in PHP 8+ канала PHP Explained
Here is str_contains() at a glance.
1. It contains the main string or the string where we are searching as the first parameter. This is called haystack.
2. The string that need to be searched is the second parameter. This is called needle.
3. This function returns boolean value - true if the string found, else false.
4. This function is case-sensitive.
5. If the search string is empty then it returns true.
6. It is introduced since version 8.
Here is an example.
We are searching string "Super" in the heredoc. The result will be true, as it is found.
$heredoc = "Math is Super easy";
$needle = "Super";
$result = str_contains($heredoc, $needle);
echo $result;
Now, we are changing the needle in small letters and search again. The result is false, because small case super is not available in the heredoc and as this function is case-sensitive.
$heredoc = "Math is Super easy";
$needle = "super";
$result = str_contains($heredoc, $needle);
echo $result;
Видео str_contains() in PHP 8+ канала PHP Explained
Комментарии отсутствуют
Информация о видео
19 июня 2025 г. 8:30:45
00:00:58
Другие видео канала
