PHP code example of guglielmopepe / callbackmapiterator
1. Go to this page and download the library: Download guglielmopepe/callbackmapiterator 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/ */
guglielmopepe / callbackmapiterator example snippets
/**
* Callback for CallbackMapIterator
*
* @param $current Current item's value
* @param $key Current item's key
* @param $iterator Iterator being filtered
* @return mixed The item after it has been applied the callback function
*/
function my_callback($current, $key, $iterator)
{
// Your code here
}
$data = ['foo','bar'];
// A callback
function my_callback($current, $key, $iterator)
{
if ($key % 2 == 0)
{
return $current;
}
return \strtoupper($current);
}
// Applies callback
$iterator = new \CallbackMapIterator\CallbackMapIterator(new \ArrayIterator($data), 'my_callback');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.