PHP Function Substr - What Are the Three Parameters That Can Be Passed to the Function Substr?
PHP offers a variety of inbuilt functions that can manipulate different types of data. One of them is the substr function that helps developers isolate a particular part of a string.
There are three parameters that can be passed to the php function substr, of which two are mandatory while the third is optional. The first parameter is the start position of the string, from which the substring is to be removed. This is an integer value and it can be positive, negative or even 0.
The second parameter is the length of the string that needs to be cut. This is also an integer value that can be positive, negative or even 0 just like the start position. If the number is negative, it indicates that a certain amount of characters will be omitted from the end of the string.
The third parameter is the length of the trimmed string that will be returned. This is an integer value that can be positive, negative, or even 0 just like the start and offset position. If no value is specified, the default value which is to the end of the string will be returned. If the trimmed string is not retrieved or any failure occurs, a False will be returned.