|
Member
|
05-27-2022
, 09:13
Re: How to get unique id from array
|
#9
|
is this stock to be called inside a function with motd?
Quote:
Originally Posted by HamletEagle
Okay, use this:
PHP Code:
getUniqueElements(input, numElements, output, &numUnique)
{
new Trie:set = TrieCreate();
new strKey[12];
for(new i = 0; i < numElements; i++)
{
num_to_str(input[i], strKey, charsmax(strKey));
if(!TrieKeyExists(set, strKey))
{
output[numUnique++] = arr[i];
TriePushCell(set, strKey, 0);
}
}
TrieDestroy(set);
}
|
|
|
|
|