PHP code example of petrobolos / fixed-array-functions
1. Go to this page and download the library: Download petrobolos/fixed-array-functions 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/ */
petrobolos / fixed-array-functions example snippets
use Petrobolos\FixedArray\FixedArrayable;
// Create using various methods
$array = new FixedArrayable([1, 2, 3]);
$array = fixedArray([1, 2, 3]); // Helper function
$array = FixedArrayable::fromCollection(collect([1, 2, 3]));
// Chain methods just like Laravel Collections
$result = fixedArray([1, 2, 3, 4, 5, 6])
->filter(fn ($value) => $value % 2 === 0)
->map(fn ($value) => $value * 2)
->sum(); // Returns 24 (2*2 + 4*2 + 6*2)
[$valid, $invalid] = fixedArray($records)
->partition(fn($record) => $record->validate())
->toArray();
// $valid contains all validated records
// $invalid contains all failed records
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.