21.07.2017, 20:12
You should loop through found categories instead of all previous categories while working with large arrays (as you mentioned this is for a furniture system? fyi: not on this thread).
Sample:
Sample:
PHP код:
enum e_array
{
something_1,
something_2,
something_3[40],
category[20]
};
new array[][e_array] =
{
{0, 380, "asdfafa", "Other"},
{0, 578, "asdfafafdsafa", "Other"},
{0, 578, "asdfafafdxsafasfadwada", "Another"},
{0, 578, "asdfafafdxsafasfawadaaasd", "Another"},
{0, 578, "asdfafafdxsafasfawadaaasdfff", "Test Something"},
{0, 578, "asdfafafdxsafasfawadaaasdffffawfwa", "Another Test"},
{0, 578, "asdfafafdxsafasfawadaaasd", "Test"},
{0, 578, "asdfafafdxsafasfawadaaasd", "Another"},
{0, 380, "asdfafa", "Test"}
};
main()
{
new categories[10][20];
for(new i = 0, j = sizeof(array), count, bool:duplicate; i < j; i ++, duplicate = false)
{
for(new k = 0; categories[k][0] != EOS; k ++)
{
if(!strcmp(array[i][category], categories[k], false))
{
duplicate = true;
break;
}
}
if(!duplicate)
{
strcat(categories[count ++], array[i][category], 20);
printf("%d %s", i, array[i][category]);
}
}
}