hi,
I have an array with duplicates:
string $myArray [] = {“item”, “something”, “something”, “item”, “other”};
and I want to check indexes for duplicates: item and something.
So I want to get this result: 0, 1, 2, 3
I managed to create an array that says what is duplicated. So I already have this array:
string $duplicates [] = {“item”, “something”};
Now I want to check the indexes of these duplicates in my initial $myArray. I can do this for a single item with a stringArrayFind command using a ’ for loop’ (since stringArrayFind returns only the first appearance not all of them at once):
int $a=0;
for ($x=0; $x < (size $myArray); $x++)
{
int $index = stringArrayFind ( $duplicates[0], $x, $myArray );
$resultIndex [$a++] = $index;
}
but no idea how to do this for multiple items. Of course I could repeat this process for $duplicates[1] and sum the results, but as you may guess this is not what I’m looking for.
Any ideas how to loop my loop?