SQL PHP HTML ASP JavaScript articles and free scripts to download

Length of an array in ASP by using UBound function

We can get the length or total number of element in the array by using UBound() function. Note that the index of the first element of the array is 0. So if there are five elements inside an array then the function UBound() will return 4. Here is the code to get the highest index of the array. Note that total element is 1 plus the highest index.

Dim myArray(3) 'Re-Declaring a dynamic array

myArray(0) = "UK"
myArray(1)="USA"
myArray(2)="Canada"
myArray(3)="UAE"
Response.Write ("Total element of the array = " & UBound(myArray) )

for i=0 to uBound(myArray)
Response.Write "<br>" & myArray(i)
Next

Here UBound is used to set the maximum looping length to display each element of the array.

In PHP array length or size is found out by using sizeof function

Be the first to post comment on this article :


Google+

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



HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer