dev-master
9999999-devA simple array manipulation class
MIT
The Requires
- php >=5.4.0
The Development Requires
helpers arrays
1.0.0
1.0.0.0A simple array manipulation class
MIT
The Requires
- php >=5.4.0
The Development Requires
helpers arrays
Wallogit.com
2017 © Pedro Peláez
A simple array manipulation class
A simple array manipulation class., (*2)
PHP >= 5.4.*, (*3)
A very common case when you need to do something like this:, (*4)
if (isset($arr['key']) {
$result = $arr['key'];
} else {
$result = 'default';
}
// another way to write the same thing
$result = isset($arr['key']) ? $arr['key'] : 'default';
With MosaicArray you can do the same thing more elegantly:, (*5)
$result = MosaicArray::make($arr)->getItem('key', 'default');
//or
$ma = new MosaicArray($arr);
$result = $ma->getItem('key', 'default');
MosaicArray implements ArrayAccess, IteratorAggregate, Countable and Serializable interfaces, so you can access an instance of this class as an array, iterate over it, count elements, serialize and unserialize it:, (*6)
$numbers = new MosaicArray([1, 2, 3]);
echo $numbers[0]; //1
foreach ($numbers as $number) {
// do something
}
echo count($numbers); // 3
serialize($numbers);
unserialize($numbers);
MosaicArray is open-source and licensed under the MIT License, (*7)
A simple array manipulation class
MIT
helpers arrays
A simple array manipulation class
MIT
helpers arrays