Script functions reference > Script functions in alphabetical order > F > FindInArray

FindInArray
Syntax
FindInArray(array_name, str);
array_name
str
Description
Searches for a value in an array. Returns the position of the array element that contains the specified value or superset of the specified value.
For example if you specify str value "10", the position of "510" is returned if it is found first.
Returns
num
-1
Example
This example has two arrays:
$arrTele containing phone numbers.
$arrAmount containing call charges.
The FindInArray function is used to search for the phone number in $arrTele.
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