SQL PHP HTML ASP JavaScript articles and free scripts to download
 

Join function to add all elements of an array to create string variable in ASP

We can create a string by joining all the elements of an array by using join() function. The out put of this function is a string variable. Here is the syntax of using join() function.

My_String = join(My_Array)

Here My_Array is the array and the My_String is the string variable which gets the string which is returned by join function after adding all the elements of the My_Array array.

While joining by default one blank space is used as delimiter, we can specify any delimiter while joining the elements by using join function. Here is the syntax of this.

my_String=join(myArray,",")

This way we can have any delimiter added between the elements while generating the string variable. In the above example comma ( , ) is used.

Here is the complete code for joining elements and creating a string variable.

Dim myArray(3) 'Declaring a dynamic array

myArray(0) = "UK"
myArray(1)="USA"
myArray(2)="Canada"
myArray(3)="UAE"

For Each item In myArray
Response.Write(item & "<br>")
Next

my_String=join(myArray,",")
Response.Write(my_String & "<br>")

Same way we can create array by breaking string using split function




Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked


Join Our Email List
Email:  
For Email Newsletters you can trust
Array