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 8.0 strpos
last run:
2023-05-10 04:12:51
11
- PHP 8.0 / MySQL 5.7 explode preg_match substr strpos
last run:
2022-02-11 21:10:03
11
- PHP 7.4 / MySQL 5.7 substr strpos
last run:
2023-06-28 11:01:30
8
- PHP 8.0 / MySQL 8.0 strtotime date strpos
last run:
2024-02-12 10:55:58
6
- PHP 8.1 / MySQL 5.7 strpos substr_count
last run:
2024-05-01 14:33:51
5
- PHP 8.0 / MySQL 8.0 strtotime date var_dump strpos
last run:
2024-02-12 11:08:11
5
- PHP 8.1 / MySQL 5.7 strpos parse_url parse_str
last run:
2023-06-23 05:25:00
5
- PHP 8.1 / MySQL 5.7 strpos
last run:
2023-04-28 17:51:10
5
- 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:
2023-04-28 17:49:08
4
strpos - New snippets
-
PHP 8.1 / MySQL 5.7 str_split strpos str_pad decbin strlen chr bindec substr
added at:
2024-08-19 08:58:00
1
-
PHP 8.1 / MySQL 5.7 str_split strpos str_pad decbin strlen chr bindec substr
added at:
2024-08-19 08:57:45
1
-
PHP 8.1 / MySQL 5.7 str_split strpos str_pad decbin strlen chr bindec substr
added at:
2024-08-19 08:56:59
1
-
PHP 8.1 / MySQL 5.7 str_split strpos str_pad decbin ltrim strlen chr bindec substr strtoupper
added at:
2024-08-19 08:34:19
1
-
PHP 8.1 / MySQL 5.7 strlen str_split strpos str_pad decbin ltrim chr bindec substr strtoupper
added at:
2024-08-19 08:32:59
1
-
PHP 8.1 / MySQL 5.7 strlen str_split strpos str_pad decbin ltrim chr bindec substr strtoupper
added at:
2024-08-19 08:32:32
1
-
PHP 8.2.13 / MySQL 8.0 preg_replace explode strpos
added at:
2024-08-06 20:11:52
1
-
PHP 8.2.13 / MySQL 8.0 preg_replace explode strpos
added at:
2024-08-06 20:11:38
1
-
PHP 8.2.13 / MySQL 8.0 preg_replace explode strpos
added at:
2024-08-06 20:11:04
1
-
PHP 8.2.13 / MySQL 8.0 preg_replace explode strpos
added at:
2024-08-06 20:10:46
1