substr
Returns a portion of a string specified by start and length parameters.
Parameters
main.php
Return Values
string
Returns the extracted part of string
On success:The portion of string specified by start and length parameters
On failure:Empty string if start is greater than string length
Notes
- If start is negative, counting starts from the end of the string
- If length is negative, that many characters will be omitted from the end
- If length is omitted, returns everything from start to end of string
- Use mb_substr() for multibyte string handling
Changelog
- 8.0.0: length is nullable
Related Functions
array_slice
ArrayExtracts a slice of an array based on offset and length parameters without modifying the original array.
sliceextractpagination
array_column
ArrayReturns the values from a single column in a multi-dimensional array or array of objects.
extractcolumndatabase
array_keys
ArrayReturns all keys or a subset of keys from an array, optionally filtered by value.
keysextractstructure