php-substr tagged requests and articles

Categorized request examples and articles tagged with [php-substr] keyword
How to get a substring from a string in PHP?
To get a substring from a string in PHP, you can use the built-in substr($string, $offset, $length) function. The $offset indicates the position at which substr() starts extracting the substring, and the optional $length parameter specifies how many characters to return, starting at offset. In PHP, indexing starts at 0. A negative value means that substr() will return a substring beginning at an $offset from the end of the string. If the optional $length parameter is passed, substr() will return the specified number of characters. If $length is negative, then the specified number of characters will be omitted at the end of the string. In this PHP Substr Example, we extract the first three characters from a string. Click Execute to run the PHP substr() function online and see the result.