![]() |
Trick for In-Array Operator
You can check if an array is inside another array by converting the array to string first:
PHP Code:
|
Nifty. Does @{1,2,3} return a string like "1,2,3" ?
What about 2-Dimensional Arrays? Does @{{1,2,3},{4,5,6},{7,8,9}} return ""1,2,3","4,5,6","7,8,9"" ? |
Yes
|
"Nifty"
o_o wtf |
Very cool =D
|
Quote:
|
Is there a way to check if only a part of an array is in the array? For example, serverr.staff is set like this:
serverr.staff="acc1,rank","acc2,rank" I want to find out if acc1 is listed in the array, without doing a loop, is it possible? I tried: ((@{"acc1",}) in serverr.staff) Wich returned 0, but if I did: ((@{"acc1","rank"}) in serverr.staff) it returned 1. But like I said, I only want to find out if "acc1" is listed, and not "rank". |
Right now not
|
Yea, this would be a good example of where I'd want to use a struct. Stefan, so much of my scripting would be cleaner if you had structs in GS2. Instead I'm stuck using parallel arrays, and ugly use of makevar.
|
Quote:
PHP Code:
|
Quote:
|
Quote:
|
For small arrays (<200 members) it is probably not a problem to cycle through it, for bigger arrays it is sometimes necessary to optimize the use of arrays a little bit to use array.index() and similar, in case you have problems with the loop limit.
|
Quote:
I do frown upon you though. Being a global, you're not being very good with PR, and you are in fact coming off as an elitist (tbh, nobody really likes elitists). Encourage others, don't look down on them. |
Quote:
|
Quote:
|
| All times are GMT +2. The time now is 02:21 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.