The substr function is used for returning the part of string.
php scripts Syntax :
The substr string function contains three basic parameters. The first parameter of the string defines original string content.
Second parameter is defining the position of the starting point.
Third parameter is the number of characters to be returned.
Sample Code in php : sample php program
php programmer Code Explanation :
In this example the “$var1” contains a set of character (or) string.
In this echo statement we call the substr string function that contains three parameters: the first parameter($var1) defines given string and the second parameter (0) as the starting positon of the string and the third parameter (20) as end of string position.
php development Sample Output :
Output is “Welcome to wikitechy technical forum” will be sub stringed using substr function where the string function has the initial value as “0” and end position of the string as “20” , so that content ( Welcome to wikitechy) will only be displayed in this output window as shown.