PHP code example of masterfermin02 / slash

1. Go to this page and download the library: Download masterfermin02/slash 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/ */

    

masterfermin02 / slash example snippets




$grouped = slash()->groupBy($this->records, 'id');

/*
 * resultado :    [
 * 1 => [ [ "id" => 1, "value1" => 5, "value2" => 10 ], [ "id" => 1, "value1" => 1, "value2" => 2 ] ], 
 * 2 => [ [ "id" => 2, "value1" => 50, "value2" => 100 ], [ "id" => 2, "value1" => 15, "value2" => 20 ] ], 
 * 3 => [ [ "id" => 3, "value1" => 15, "value2" => 20 ] ]   
 *   ];
*/


 

slash()->map([1, 2, 3], fn ($n) => $n * 2);  // === [2, 4, 6]


slash()->max([1, 2, 3]) // => 3

slash()->flatten([1, [2, [3]]]) // => [1, 2, 3]

slash()->last([1, 2, 3], 2) // => [2, 3]