Yes, there are some standard PHP (Standard PHP Library) classes in PHP that do the job well.
Generally these classes implement the interfaces
ArrayAccess interface allows access and definition of class members as if it were a
Here are some examples:
This class works like a stack. When you add an element via
SplStack $stack , instead of adding the element at the end as it does in an ordinary array, it adds to the beginning.
$stack = new SplStack;
$stack = 1;
$stack = 2;
$stack = 3;
This would return:
2 => 3,
1 => 2,
0 => 1,
SplFixedArray class is used to determine a fixed number of elements for a
array . You determine in the instance how many elements will be present in that structure. It is similar to the
$arr = new SplFixedArray(3);
$arr = 0;
$arr = 1;
$arr = 2;
Some people say that they did tests and got an economy 33% less than a% of common%, but that's the kind of thing I do not usually focus on.
This class is for you to store objects. The big difference is that when you define an object in it, it is passed as the index of that "structure".
$s = new SplObjectStorage();
$o1 = new StdClass;
$o2 = new StdClass;
$o3 = new StdClass;
$s[$o1] = "data for object 1";
$s[$o2] = array(1,2,3);
These are some examples, but there are others, which have already been mentioned by @rray.