PHP code example of webtechnick / laravel-macros
1. Go to this page and download the library: Download webtechnick/laravel-macros 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/ */
webtechnick / laravel-macros example snippets
$col = collect(['foo', 'bar', 'baz']);
for ($i = 0; $i < count($col); $i++) {
echo $col[$i];
}
// foo, bar, baz. expected.
$colreverse = $col->reverse();
for ($i = 0; $i < count($colreverse); $i++) {
echo $colreverse[$i];
}
// also foo, bar, baz because keys are preserved by default. unexpected.
$colnopreserve = $col->noPreserveReverse();
for ($i = 0; $i < count($colnopreserve); $i++) {
echo $colnopreserve[$i];
}
// baz, bar, foo. expected.