1. Go to this page and download the library: Download transprime-research/arrayed library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Transprime\Arrayed\Arrayed;
// Nifty
arrayed(1, 2)->count();
// Easier
Arrayed::on(1, 2)->count();
// Normal with (new instance)
(new Arrayed(1,2))->count();
//Non associative
arrayed(1, 2);
//OR
arrayed([1, 2]);
// For associative array, only this way
arrayed(['a' => 1, 'b' => 2]);
arrayed(1,2)->collect(); // instance of Illuminate/Support/Collection
arrayed(1,2)->collect(3, 4); //merged with first one to give [1, 2, 3, 4]
collect(arrayed(1, 2, 3, 4));
// Or
new Collection(arrayed(1, 2, 3, 4));
// Or
Collection::make(arrayed(1, 2, 3, 4));
response()->json(arrayed(1, 2, 3)->flip());
arrayed(1, 2, 3)
->tap(function ($arrd) {
logger('Array has '.$arrd->count());
});
arrayed(['a' => 1, 'b' => 2])
->values() // returns array, we can chain
->sum(); // returns an integer, we cannot chain