← All built-ins / substr()
substr()
substr(...$args): string
Parameters
| Name | Type | Description |
|---|---|---|
| $s | string | input string |
| $start | int | start position (negative = from the end) |
| $len | int | maximum length; omitted = to the endoptional |
Return value
The extracted substring.
Example
echo substr("HolyPHP", 0, 4), "
";
echo substr("HolyPHP", 4), "
";
echo substr("HolyPHP", -3), "
";Holy PHP PHP