![]() ![]() ![]() Here “,” is the Separator1 parameter, “$strab” is the original string element which is nothing but OriginalString1 parameter, “2” is the No.ofElements1/limit Parameter. Then print_r() function is used along with the explode() function along with the three parameters. Here at first, a string variable called “$strab” is created with the string value ‘car1, bus1, motorbike1, cycle1’. This is the example of implementing the string splitting with the help of the positive integer as No.ofElements1/limit Parameter. Then print function is used to print line break. This will be printed as shown in the output. It is mentioned in the parameters description that if the No.ofElements1/Limit value is mentioned as 0 then the whole original string is considered as one single string array element. In the explode() function, “,” is used as separator1 parameter, $stra variable value is used as OriginalString1 Parameter and value “0” is used as No.ofElements1 Parameter. Then print_r() function is made along with the explode() function in it. At first, a variable “$stra” is created and this variable is also assigned with a string value ‘car1, bus1, motorbike1, cycle1’. This is the example of implementing with limit value “0”. After splitting, inside of the array index values small strings will be stored and printed with the help of the print_r() function. There is no limit/No.ofElements1 parameter here so there is no limit to splitting of the string. Here separator1/delimeter parameter is space “ ”, $s1 is the input parameter/Original String and then here no parameter is mentioned. Then print_r() function is used along with the explode() function in it. In the below example inside of the PHP tags, a variable “$s1” is created and assigned a string sentence to the $s1 variable. This is the example of splitting a single string into many small string by taking the space in between the string into the consideration. Given below are the examples mentioned: Example #1 The return value type of the explode() function is the single array with the list of the strings. When no value is passed to this No.ofElements1 parameter then array returned will be going to have total number of elements formed after the string separation with the separator. Zero Integer: If the No.ofElements1 parameter is passed with “Zero” value then the array which is going to return only one string element i.e., Full String (whole string).Negative Integer (N): If the negative integer is passed to the No.ofElements1 parameter then last string element N will be trimmed and the remaining array element will be returned as only one single string.If number of elements after separating the elements w.r.t the separator will emerge as to be the value greater then N-1 elements but remains same and the last string element will be the whole remaining string. Positive Integer (N): If No.ofElements1 parameter is passed with Positive Integer value then it means array will contain this number of string elements.It can be positive integer, negative integer or the zero integer. This parameter can be of any type of integer. This parameter helps in specifying the number of array elements. No.ofElements1/Limit: This Parameter is an optional parameter and it’s not mandatory. This OriginalString1 parameter is also a mandatory parameter.ģ. OriginalString1: The OriginalString1 Parameter of the PHP Programming Language is actually an original string which is used to split a string into many strings and stores in an array only if the string characters are available inside of the string. This delimeter/Separator1 parameter is a mandatory parameter.Ģ. Separator1/Delimeter: The Separator1 Parameter of the PHP Programming Language actually specifies some critical points at which point the string has to split which means that whenever the string character will be found in the string element then it is going to symbolize the end of one array element and start of the another. The Parameters of the explode() function are actually accepting three parameters but in those only two parameters are mandatory and one parameter is an optional parameter.ġ. All these smaller string elements are stored in array with index values and also based on the parameters of the explode() function. It works by splitting the string into smaller strings with the help of the parameters inside the explode() function. They are Separator1, OriginalString1 and No.ofElements1 Parameter. The explode() function of the PHP Programming Language works based on the three parameters mentioned. Explode(separator1, OriginalString1, No.ofElements1) How explode() Function works in PHP? ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |