PHP substr() is an inbuilt string function that returns a part of a string. The substr() method extracts parts of the string, beginning at the character at the specified position, and returns the specified number of characters.

If you want to extract a part of string, then you can use the PHP substr() function.

PHP substr() method does not change an original string. If we want to extract characters from the end of the string, use a negative start number.

PHP Substr Example

PHP substr() function used to cut a part of a string from a string, starting at a specified position.

PHP substring is one of the most common PHP string functions. It returns the part of the string. The first argument specifies the** string,** which will be trimmed.

The second argument specifies the position of the trim start. The third argument specifies the length of a string to be returned. The start and length arguments can also be negative numbers.

#php #php substr

PHP String Substr Example | PHP substr() Function
2.10 GEEK