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

Further readings
Declaring Fixed and Dynamic size array in ASP
Getting size of an array
Creating arrays by splitting string using split() function
Joining elements of an array to create a string variable
Searching inside array elements for matching string using Filter
 
Scripts
PHP
JavaScript
All ASP Tutorials
Popular Tutorials
Managing two drop downs
ASP Tutorials
Date and time
Declaring array
Form in ASP
Server.MapPath
Date Time & MSSQL
Select Query
File System Object
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.