<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
guglielmopepe / recursivecallbackmapiterator example snippets
/**
* Callback for RecursiveCallbackMapIterator
*
* @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'=>['foo','bar'],'bar'=>['bar','foo']];
// A callback
function my_callback($current, $key, $iterator)
{
if ($key % 2 == 0)
{
return $current;
}
return \strtoupper($current);
}
// Applies callback
$iterator = new \RecursiveCallbackMapIterator\RecursiveCallbackMapIterator(new \RecursiveArrayIterator($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.