![]() Tonight Example: Using substr() function with negative length The function returns the string which is at the seventh index from the end of the string. In the given example, we have specified the negative index for the extracted string. Studytonight Example: Using substr() function with negative value So the output string will start from the index 11 and end at the end of the string. In the even example, we have used the substr() function but do not specify the length of the extracted string. ![]() To Example: Using substr() function will default length argument The substring starts with the index 8 and the length of the string is 2. In the given example, we have used the substr() function to extract the substring from the input string. $length specifies the length of the extracted string. ![]() It specifies the position at which the function begins to extract the substring. $start specifies where to start the string the needs to be extracted. In the first parameter, we have to specify the input string and the second parameter specifies the position at which the function begins to extract the substring from the input string, and the third-string specifies the length of the characters that are to be extracted from the input string. Out of three parameters, the first two parameters are necessary to specify while the third one is optional. This function takes three parameters that are string, start length, and the length of the extracted string. This function is used to extract the substring from any given string. The substr() function is a pre-defined PHP function.
0 Comments
Leave a Reply. |