Documentation

SuperGlobalArray
in package

SuperGlobalArray is threaded array which is reachable from any thread, and it has no a parent thread. Super global array does not support resources and Closure.

Super global array does not require synchronization before to do any actions. However, if one thread is handling super global array data in a loop, another threads may work slowly in any actions with super global array.

To avoid errors, it is recommended do not work with large amounts of data. It is also recommended not to read the entire super global array just to get one element of the array. Such actions when using the super global array with several threads in one time, if the array has a large amount of data, the behavior of the array can become unpredictable.

The first argument of any SuperGlobalArray method (except GetInstance() which doesn't have any arguments) is array path. So, if you want to do some actions like that: $foo = $arr["subarray"]["subsubarray"]["bar"];

you have to use this: $arr = SuperGlobalArray::GetInstance(); $foo = $arr->Get(["subarray", "subsubarray", "bar"]);

Table of Contents

Add()  : void
Addes value to array with numeric index
Get()  : mixed
Returns value of array key
GetInstance()  : SuperGlobalArray
Returns instance of super global array
IsSet()  : bool
Returns TRUE if item with same key exists
Operator()  : mixed
Executes operator with array item
Set()  : void
Sets new value for key
Unset()  : void
Deletes item in array, like native PHP `unset()` function

Methods

Add()

Addes value to array with numeric index

public Add(array<string|int, string> $keys,  $value) : void
Parameters
$keys : array<string|int, string>

Path to value. For example, if you want to make thing like this: $array["hello"]["world"][] = $value, use this: Add(["hello", "world"], $value)

$value :

mixed Value

Tags
throws
ItemIsNotArrayException
throws
KeyNotFoundException
throws
UnknownErrorException
Return values
void

Get()

Returns value of array key

public Get(array<string|int, string> $keys) : mixed
Parameters
$keys : array<string|int, string>

Path to value. For example, if you want to make thing like this: $array["hello"]["world"]["foo"]["bar"], use this: ["hello", "world", "foo", "bar"]

Tags
throws
ItemIsNotArrayException
throws
KeyNotFoundException
throws
UnknownErrorException
Return values
mixed

Operator()

Executes operator with array item

public Operator(array<string|int, string> $keys, string $operator[, mixed $value = "" ]) : mixed
Parameters
$keys : array<string|int, string>

Path to value

$operator : string

Required operator. Available operators: ".=", "+=", "-=", "*=", "/=", "++", "--"

$value : mixed = ""

Value for operator. Isn't using with "++" and "--" operators

Tags
throws
InvalidOperatorException
throws
InvalidValueTypeException
throws
ItemIsNotArrayException
throws
KeyNotFoundException
Return values
mixed

Set()

Sets new value for key

public Set(array<string|int, string> $keys,  $value) : void
Parameters
$keys : array<string|int, string>

Path to value. For example, if you want to make thing like this: $array["hello"]["world"]["foo"]["bar"], use this: ["hello", "world", "foo", "bar"]

$value :

mixed Value

Tags
throws
ItemIsNotArrayException
throws
KeyNotFoundException
throws
UnknownErrorException
Return values
void

Search results