Creating arrays by breaking strings using split functionWe can break a string and create an array by using split() function in ASP ( VBScript). We can decide what way the array to be created by breaking the string. If we break the string by using one space as a delimiter then the array will contain all words of the string. Same way we can take any other delimiter like coma ( , ) or any other character and generate an array by breaking the string. Here is the syntax of split function.
Here My_String is the string variable and we are using one space length as delimiter and breaking the string. We will get our array in the variable My_Array.
We can restrict the total elements of the array by specifying another options parameter to split function. This way the last element will contain rest of the string. This example will make it simple.
Here is the value of each item of the array we get after the split function
You can see the last element contains all the words of the string.
Here is the full code
Same way we can create one string by joining all elements of an array by using Join() function.
Split function in PHP to create an array by breaking a string
This article is written by plus2net.com team.
Number of User Comments : 1