slice.php
Table of Contents
Functions
- slice() : string
- Extracts a substring from a UTF-8 encoded string using grapheme clusters, which ensures multi-byte characters (like emojis, accented letters) are not broken.
Functions
slice()
Extracts a substring from a UTF-8 encoded string using grapheme clusters, which ensures multi-byte characters (like emojis, accented letters) are not broken.
slice(string|null $source[, int $start = 0 ][, int|null $length = null ]) : string
If the source is null, it returns an empty string.
Parameters
- $source : string|null
-
The input string or null.
- $start : int = 0
-
The start position (0-based). Negative values count from the end.
- $length : int|null = null
-
The length of the substring. Defaults to max int (whole string from $start).
Tags
Return values
string —The extracted substring or empty string if $source is null.