Go to: Synopsis. Return value. MEL examples.

Synopsis

int stringArrayCount(string $item, string[] $list)

Return the number of times the string in $item occurs in the string array $list. Zero is returned if the string is not in the list.

Return value

None

Arguments

Variable Name Variable Type Description
$itemstringThe string item to search for in the string array.
$liststring[]A list of string values.

MEL examples

  string $array1[] = {"item1", "item2", "item1"};
  // Result: item1 item2 item1 //
  int $count = stringArrayCount("item1", $array1);
  // Result: 2 //
  $count = stringArrayCount("item2", $array1);
  // Result: 1 //
  $count = stringArrayCount("plotz", $array1);
  // Result: 0 //