javaguirre / php-extended-array
Extended Array for PHP
dev-master
2015-06-18 17:11 UTC
Requires (Dev)
- phpunit/phpunit: >=4.0.0
This package is not auto-updated.
Last update: 2025-01-04 19:42:38 UTC
README
Just a simple extension of the PHP array using ArrayObject
Install
Edit your composer.json file to require javaguirre/php-extended-array
and run composer update
"require": { "javaguirre/php-extended-array": "dev-master" }
Usage
<?php use TA\ExtendedArray\Type\ExtendedArray; $fruits = new ExtendedArray( array( 'tropical' => 'pineapple', 'farm' => 'strawberry' ) ); $fruits->has('tropical'); // true $fruits->hasOne(array('tropical', 'asian')); // true $fruits->hasAll(array('tropical', 'asian')); // false $fruits->get('canary', 'banana'); // 'banana' $fruits->get('tropical', 'banana'); // 'pineapple' $fruits->getSubArray(array('tropical')); // array('tropical' => 'pineapple'); $fruits->toArray(); // array('tropical' => 'pineapple', 'farm' => 'strawberry');
Key access
You can access properties as If it was an object or an array
$fruits->tropical; // 'pineapple' $fruits['tropical']; // 'pineapple'