strpos
strpos — Find the position of the first occurrence of a substring in a string.Description
strpos( string $haystack,Find the numeric position of the first occurrence of needle in the haystack string.
string $needle,
int $offset = 0 ): int|false
Parameters
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.
Return Values
Returns the position of where the needle exists relative to the beginning of the haystack string (independent of offset). Also note that string positions start at 0, and not 1.Returns false if the needle was not found.
More information about strpos on official PHP documentation site
strpos - Popular snippets
- PHP 8.0 / MySQL 5.7 explode preg_match substr strpos
last run:
2022-02-11 21:10:03
11
- PHP 8.0 / MySQL 5.7 strpos strlen substr intval var_dump
last run:
2022-02-03 12:42:38
5
- PHP 8.1 / MySQL 5.7 strpos
last run:
2022-06-09 06:29:22
3
- PHP 8.0 / MySQL 5.7 strpos strlen substr intval var_dump
last run:
2022-02-03 15:47:31
3
- PHP 8.0 / MySQL 5.7 strpos substr str_pad
last run:
2022-01-23 08:08:02
3
- PHP 8.0 / MySQL 5.7 strpos strrpos strlen substr var_dump
last run:
2021-09-17 15:18:03
3
- PHP 5 / MySQL 5.7 var_dump array_intersect strpos preg_replace trim
last run:
2021-08-23 21:08:51
3
- PHP 8.1 / MySQL 5.7 strpos
last run:
2022-06-09 06:29:26
2
- PHP 7 / MySQL 5.7 strpos
last run:
2022-04-18 09:26:34
2
- PHP 7 / MySQL 5.7 strpos
last run:
2022-04-18 09:35:04
2
strpos - New snippets
-
PHP 8.1 / MySQL 5.7 strpos
added at:
2022-06-09 06:29:10
2
-
PHP 8.1 / MySQL 5.7 strpos
added at:
2022-06-09 06:29:04
1
-
PHP 8.1 / MySQL 5.7 strpos
added at:
2022-06-09 06:18:37
3
-
PHP 8.1 / MySQL 5.7 strpos var_dump implode
added at:
2022-06-09 06:17:18
1
-
PHP 8.1 / MySQL 5.7 strpos var_dump implode
added at:
2022-06-09 06:17:07
1
-
PHP 8.1 / MySQL 5.7 var_dump strpos
added at:
2022-06-03 13:11:06
1
-
PHP 5 / MySQL 5.7 strpos
added at:
2022-05-27 12:15:58
1
-
PHP 5 / MySQL 5.7 var_dump strpos
added at:
2022-05-27 12:15:47
1
-
PHP 5 / MySQL 5.7 var_dump strpos
added at:
2022-05-27 12:15:36
1
-
PHP 5 / MySQL 5.7 strpos
added at:
2022-05-27 12:15:21
1