Last active
December 17, 2015 14:49
-
-
Save ephrin/5626797 to your computer and use it in GitHub Desktop.
Test of test v0.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$array = array('_0' => 0); | |
$array = new ArrayHelper($array); | |
$func = function ($key, $value, ArrayHelperInterface $array) { | |
static $i; | |
$i++; | |
$c = count($array); | |
if (is_string($key) && $c < $value) { | |
unset($array[$key]); | |
return true; | |
} else { | |
$array['_'.$i] = --$c; | |
return false; | |
} | |
}; | |
$array->each($func); | |
var_dump(iterator_to_array($array)); | |
/* | |
array(2) { | |
'_0' => | |
int(0) | |
'_1' => | |
int(0) | |
} | |
*/ | |
$array->some($func); | |
var_dump(iterator_to_array($array)); | |
/* | |
array(4) { | |
'_0' => | |
int(0) | |
'_1' => | |
int(0) | |
'_2' => | |
int(1) | |
'_3' => | |
int(2) | |
} | |
*/ | |
$array->every($func); | |
var_dump(iterator_to_array($array)); | |
/* | |
array(5) { | |
'_0' => | |
int(0) | |
'_1' => | |
int(0) | |
'_2' => | |
int(1) | |
'_3' => | |
int(2) | |
'_4' => | |
int(3) | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment