$args is an array and each of its elements are passed to the callback as separate arguments.
so this is the right way to get args:
<?php
$ai = new ArrayIterator(range(0, 2));
iterator_apply($ai, function() {
var_dump(func_get_args()); return true;
}, array(1, 2));
?>
output:
array(2) {
[0] =>
int(1)
[1] =>
int(2)
}
array(2) {
[0] =>
int(1)
[1] =>
int(2)
}
array(2) {
[0] =>
int(1)
[1] =>
int(2)
}
--------------------------------------------------
or list each args:
<?php
$ai = new ArrayIterator(range(0, 2));
iterator_apply($ai, function($arg1, $arg2, $arg3) {
var_dump([$arg1, $arg2, $arg3]);
return true;
}, array(1, 2));
?>
same output.