// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: 04 January 1999 // // // // // // 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. // // // string $item The string item to search for in the string array. // string[] $list A list of string values. // // // int : The number of occurrences of the string item in the string array. // // // 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 // // // // global proc int stringArrayCount(string $item, string $list[]) { int $result = 0; string $listItem; for ($listItem in $list) { if ($item == $listItem) $result++; } return $result; }