![]() |
Array Search
Ok, nother problem. So out of scripting.
I can't by the slightest remember how to search an array and find out if a var is in it. Example. Have an array of account names and want to do and if account name is in array, then allow. |
PHP Code:
|
Also remember you can do this for caps-insensitive searching...
PHP Code:
|
those b them, ty.
|
Note that if you're working with a really, really big dataset, it may be faster to use something like a scripted binary search (I think there might be one in the code gallery, if not I could write one).
|
Searching Arrays, like REALLY searching them is possible in PHP, not sure if it works in GS2
|
Its only going to be 10 accounts max probably, ever.
|
Another question arises, how do i add to a server array? i know how to set, serverr.whatever = {whatever, whatever} but if I want to add and delete from that, how should I go about it?
|
Quote:
You'll find these functions which may be of use to you: obj.add(obj2) - adds an object to an array obj.delete(index) - deletes the object from an array at the specified index obj.remove(obj2) - removes the first instance of the specified object from the array obj.replace(index,obj2) - replace the object at the specified index obj.insert(index,obj2) - insert the object at the index without replacing other indexes |
Quote:
go to wiki.graal.us! |
Quote:
|
thanks for the site! completely forgot about it.
|
| All times are GMT +2. The time now is 11:47 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.