Container
class Container (View source)
Container utility class
Constants
| MODIFIABLE |
Container is modifiable. Container property flag. |
| EXTENDABLE |
Container can accept new elements. Container property flag. |
| SHRINKABLE |
Elements can be removed from container Container property flag. |
| TRAVERSABLE |
Container can is traversable. Container property flag. |
| COUNTABLE |
Number of elements contained is available Container property flag. |
| RANDOM_ACCESS |
Container elements can be accessed using a arbitrary random access method. Container property flag. |
| PROPERTY_ACCESS |
Container elements can be accessed by using the arrow operator. Container property flag. |
| OFFSET_ACCESS |
Container elements can be accessed by using the bracket operator. Container property flag. |
| IMPLODE_KEYS |
The container element key will be passed to the user-defined callable. Container::implode() function callable argument selection flag. |
| IMPLODE_VALUES |
The container element value will be passed to the user-defined callable; Container::implode() function callable argument selection flag. |
| IMPLODE_BEFORE |
String to prepend before each array element. |
| IMPLODE_AFTER |
String to append after each array element. |
| IMPLODE_BETWEEN |
String to insert between two elements of the array. |
| IMPLODE_BETWEEN_LAST |
String to insert between the penultimate and last element of the array. |
| MERGE_RECURSE |
|
| MERGE_LIST_REPLACE |
|
Methods
Get the kind of operation supported by a given container
Indicates if the parameter is an array or an object which implements ArrayAccess interface (PHP 5)
Indicates if the parameter is an array or an object which
Get the list of keys of the given container
No description
Get the list of values of the given container.
Remove an entry from the given container
Remove first entry from container and return its value.
Remove last entry from container and return its value.
Transform any type to a plain PHP array
Indicates if the given container could be considered as an indexed array
Iterate container and return the value of the nth element.
Indicates if the given array is an associative array
No description
Indicates if a key exists in an array or a ArrayAccess implementation
Indicates if the given value appears in the container elements
Get the first key and value of the given container.
Get the first key of the given container
Get the first value of the container.
Get the last key-value pair in the given container
Get the last key of the given container
Get the last value of the container.
Retrieve key value or a default value if key doesn't exists
No description
Add a value at the end of the container value list.
Add a value at the beginning of the container value list.
Implode array values
Implode array keys
Implode an array
Returns an array containing the results of applying the callback to each of input container elements.
Returns an array containing the results of applying the callback to each of input container elements.
Applies the user-defined callback function to each element of the container $container.
Sort array values and maintain index association
Sort an array using a case insensitive "natural order" algorithm
Sort an array with a user-defined comparison function and maintain index associatio
Sort an array by keys using a user-defined comparison function
Removes duplicate values from an container
Merge two or more container
No description
Details
at line 151
static integer
properties(mixed $container, bool $fromContainerPropertyInterface = false)
Get the kind of operation supported by a given container
at line 204
static
isArray(mixed $container)
Indicates if the parameter is an array or an object which implements ArrayAccess interface (PHP 5)
at line 217
static boolean
isTraversable($container)
Indicates if the parameter is an array or an object which
at line 232
static array
keys(mixed $container)
Get the list of keys of the given container
at line 257
static boolean
isEmpty(mixed $container)
at line 270
static mixed[]
values(mixed $container)
Get the list of values of the given container.
at line 300
static boolean
removeKey(mixed $container, mixed $key)
Remove an entry from the given container
at line 336
static mixed
shift(mixed $container)
Remove first entry from container and return its value.
at line 357
static mixed
pop(mixed $container)
Remove last entry from container and return its value.
at line 379
static array
createArray(mixed $anything, number $singleElementKey = null)
Transform any type to a plain PHP array
at line 435
static boolean
isIndexed(mixed $container, boolean $strict = false, boolean $allowEmpty = true)
Indicates if the given container could be considered as an indexed array
An indexed array is a container where keys are a sequence of integers starting from 0 to n-1. (where n is the number of elements of the container)
An empty container is always considered as an indexed array
Complexity : 𝛰(n)
at line 478
static The
nthValue(mixed $container, integer $offset, mixed $dflt = null)
Iterate container and return the value of the nth element.
at line 508
static boolean
isAssociative(array|ArrayAccess|Traversable $container, boolean $strict = false, boolean $allowEmpty = true)
Indicates if the given array is an associative array
An empty container is always considered as associative
Complexity : 𝛰(n)
at line 557
static
count($container)
at line 582
static
reset(array|ArrayAccess $container)
Reset array pointer to initial value or rewind an Iterator
at line 607
static boolean
keyExists(array|ArrayAccess|Traversable $container, mixed $key)
Indicates if a key exists in an array or a ArrayAccess implementation
at line 647
static boolean
valueExists(array|ArrayAccess|Traversable $container, mixed $value, boolean $strict = false)
Indicates if the given value appears in the container elements
at line 690
static array
first($container, $dflt = array())
Get the first key and value of the given container.
at line 732
static mixed
firstKey($container, $dflt = null)
Get the first key of the given container
at line 750
static mixed
firstValue(mixed $container, mixed $dflt = null)
Get the first value of the container.
at line 769
static array
last(mixed $container, array $dflt = array())
Get the last key-value pair in the given container
at line 830
static mixed
lastKey($container, $dflt = null)
Get the last key of the given container
at line 849
static mixed
lastValue(mixed $container, mixed $dflt = null)
Get the last value of the container.
at line 872
static mixed
keyValue(array $container, integer|string $key, mixed $defaultValue = null)
Retrieve key value or a default value if key doesn't exists
at line 941
static mixed
treeValue($container, $keyTree, $dflt = null, $keySeparator = '.')
at line 973
static
setValue(array|ArrayAccess|Traversable $container, mixed $key, mixed $value)
at line 1023
static
appendValue(array|ArrayAccess|object $container, mixed $value)
Add a value at the end of the container value list.
at line 1083
static
prependValue(array|ArrayObject|object $container, mixed $value)
Add a value at the beginning of the container value list.
at line 1174
static string
implodeValues($container, $glue, $callable = null, $callableArguments = array())
Implode array values
at line 1226
static string
implodeKeys($container, $glue, $callable = null, $callableArguments = array())
Implode array keys
at line 1282
static string
implode(array $container, string $glue, callable $callable, string $callableArguments = array())
Implode an array
at line 1323
static array
filter(array|Traversable $container, callable $callable)
at line 1348
static array
filterValues(array|Traversable $container, callable $callable)
Filter container elements by values
at line 1379
static array
filterKeys(array|Traversable $container, callable $callable)
Filter container elements by keys
at line 1410
static array
map(mixed $container, callable $callable)
Returns an array containing the results of applying the callback to each of input container elements.
at line 1450
static array
mapValues(mixed $container, callable $callable)
Returns an array containing the results of applying the callback to each of input container elements.
at line 1484
static $container
walk(mixed $container, callable $callable)
Applies the user-defined callback function to each element of the container $container.
at line 1522
static boolean
asort(array|ArrayObject $container, integer $flags = \SORT_REGULAR)
Sort array values and maintain index association
at line 1543
static boolean
ksort(array|ArrayObject $container, integer $flags = \SORT_REGULAR)
Sort an array by keys
at line 1562
static boolean
natsort(array|ArrayObject $container)
Sort an array using a "natural order" algorithm
at line 1581
static boolean
natcasesort(array|ArrayObject $container)
Sort an array using a case insensitive "natural order" algorithm
at line 1603
static boolean
uasort(array|ArrayObject $container, callable $callable)
Sort an array with a user-defined comparison function and maintain index associatio
at line 1625
static boolean
uksort(array|ArrayObject $container, callable $callable)
Sort an array by keys using a user-defined comparison function
at line 1648
static mixed[]
uniqueValues(unknown $container, unknown $comparer = null)
Removes duplicate values from an container
at line 1728
static array
merge()
Merge two or more container