PHP code example of jonpemby / phlash

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

    

jonpemby / phlash example snippets


$collection = phlash([1, 2, 3, 4, 5, 6])->dropRight(3);  // [1, 2, 3]
$collection = phlash([1, 2, 3, 4, 5, 6])->drop_right(3); // [1, 2, 3]
$collection = phlash([1, 2, 3, 4, 5, 6])->DropRight(3);  // [1, 2, 3]

$collection = phlash([1, 2, 3, 4, 5, 6]);
// Phlash\Arr {#210}

$another = $collection->map(function ($value) {
    return $value * 2;
});
// Phlash\Arr {#217}

Phlash\Arr::from()->fill(null, 0, 3);
// [null, null, null]

phlash([])->fill(null, 0, 3);
// [null, null, null]

fill([], null, 0, 3);
// [null, null, null]

$array = phlash([
    ['foo' => 1],
    ['foo' => 2],
    ['foo' => 3],
    ['foo' => 4],
    ['foo' => 5],
    ['foo' => 6],
]);

$array->foo;
// [1, 2, 3, 4, 5, 6]