preg_split
preg_split — Split string by a regular expression.Description
preg_split( string $pattern, string $subject, int $limit = -1, int $flags = 0 ): array|falseSplit the given string by a regular expression.
Parameters
pattern
The pattern to search for, as a string.
subject
The input string.
limit
If specified, then only substrings up to limit are returned with the rest of the string being placed in the last substring. A limit of -1 or 0 means "no limit".
flags
flags can be any combination of the following flags (combined with the | bitwise operator):
PREG_SPLIT_NO_EMPTY
If this flag is set, only non-empty pieces will be returned by preg_split().
PREG_SPLIT_DELIM_CAPTURE
If this flag is set, parenthesized expression in the delimiter pattern will be captured and returned as well.
PREG_SPLIT_OFFSET_CAPTURE
If this flag is set, for every occurring match the appendant string offset will also be returned. Note that this changes the return value in an array where every element is an array consisting of the matched string at offset 0 and its string offset into subject at offset 1.
Return Values
Returns an array containing substrings of subject split along boundaries matched by pattern, or false on failure.More information about preg_split on official PHP documentation site
preg_split - Popular snippets
- PHP 8.1 / MySQL 5.7 preg_split
last run:
2024-04-06 02:37:20
6
- PHP 8.0 / MySQL 5.7 preg_split print_r
last run:
2023-11-12 20:29:40
6
- PHP 8.0 / MySQL 5.7 preg_split print_r
last run:
2023-11-12 20:36:17
6
- PHP 7.4 / MySQL 8.0 preg_split print_r
last run:
2021-07-12 17:12:23
5
- PHP 8.1 / MySQL 5.7 var_dump preg_split
last run:
2022-06-20 15:06:10
4
- PHP 7.4 / MySQL 5.7 preg_split var_dump json_decode
last run:
2022-10-18 13:38:44
3
- PHP 7.4 / MySQL 5.7 preg_split var_export
last run:
2022-10-14 10:16:47
3
- PHP 8.1 / MySQL 5.7 preg_split var_export
last run:
2022-09-17 10:29:56
3
- PHP 8.1 / MySQL 5.7 var_dump preg_split
last run:
2022-06-20 15:05:35
3
- PHP 8.0 / MySQL 5.7 preg_split var_dump
last run:
2021-12-19 07:18:57
3
preg_split - New snippets
-
PHP 8.1 / MySQL 5.7 is_null trim preg_split var_dump count is_numeric print_r preg_match
added at:
2024-09-06 08:41:30
1
-
PHP 8.1 / MySQL 5.7 is_null trim preg_split count is_numeric print_r preg_match
added at:
2024-09-06 08:25:29
1
-
PHP 8.1 / MySQL 5.7 implode array_map preg_replace join array_reverse preg_split explode
added at:
2024-08-28 14:42:44
1
-
PHP 8.0 / MySQL 5.7 preg_split trim fgets array_map array_unique count
added at:
2024-06-27 12:25:49
1
-
PHP 8.0 / MySQL 5.7 preg_split array_map array_unique count
added at:
2024-06-27 12:22:48
1
-
PHP 8.0 / MySQL 5.7 preg_split array_map array_unique count
added at:
2024-06-27 12:22:21
1
-
PHP 8.0 / MySQL 5.7 preg_split array_map array_unique count
added at:
2024-06-27 12:21:57
1
-
PHP 8.0 / MySQL 5.7 preg_split array_map array_unique count
added at:
2024-06-27 12:21:54
1
-
PHP 8.0 / MySQL 5.7 preg_split array_map var_dump array_unique count
added at:
2024-06-27 12:21:07
2
-
PHP 8.0 / MySQL 5.7 preg_split array_map array_unique count
added at:
2024-06-27 12:20:46
1