39b33a28bbe9afd35fec83c3e0f2dfcf3a23ef5f
Ary
Are you tired from casting objects and array to each other? Ary is a light class/function that makes accessing array items more convenient.
- You can access array items using
->
or[]
syntax. - You will get
null
if an index does not exists. - You can specify a default value for a missing index.
// instantiation
$ary = new Ary();
// or simply
$ary = ary();
//setting and getting array items.
$ary = ary(2, 4, 6, 8); //or
$ary = ary([2, 4, 6, 8]); //or
$ary = ary(['x' => 'foo', 'y' => 'bar']);
$foo = $ary->foo; //or
$foo = $ary['foo'];
$missed = $ary->get('missed', 'Default value');
$ary->newItem=20; //or
$ary['newItem']=20;
count($ary); //returns 3
$ary->all(); // returns simple php array;
Description
Ary makes PHP's array syntax more flexible and provides some really necessary utility methods.
Languages
PHP
100%