Script functions reference > Script functions in alphabetical order > A > ArraySize

ArraySize
Syntax
ArraySize(array_name);
array_name
Description
Counts the number of elements stored in an array.
Returns
num
Examples
Example 52
In this example, ArraySize is used to count the numbers in the array $arr.
$arr[0]="Mike Jones";
$arr[1]="Bill Carlson";
$arr[2]="Eve Smith";
$numberOfItems=ArraySize($arr);
When the script is run, $numberOfItems gets the value 3.
 
Example 53
In this example, ArraySize is used to count the numbers in the array $arr.
$arr[0][0]="Mike";
$arr[0][1]="Jones";
$arr[1][0]="Bill";
$arr[1][1]="Carlson";
$arr[2][0]="Eve";
$arr[2][1]="Smith";
$numberOfItems=ArraySize($arr);
When the script is run, $numberOfItems gets the value 3, i.e. the same result as in the previous example.
 
Example 54
This example has two arrays:
$arrTele containing phone numbers.
$arrAmount containing call charges.
If a phone number for a specific call is found in $arrTele, the charge for the call should be added to the corresponding position in $arrAmount.
If the phone number is not found, the new phone number should be added to $arrTele and the new charge to $arrAmount. The ArraySize function specifies the position where to add the new number and charge at the end of the arrays.
$retIndex=FindInArray($arrTele, $noDialled);
if ($retIndex="-1")
   {
      $retSize=ArraySize($arrTele);
      $arrTele[$retSize]=$noDialled;
      $arrAmount[$retSize]=$callCharge;
   }
else
    $arrAmount[$retIndex]=$callCharge;
 
OpenText StreamServe 5.6 Updated: 2013-03-01