note 121897 added to function.iterator-apply

From: Date: Wed, 22 Nov 2017 06:47:21 +0000
Subject: note 121897 added to function.iterator-apply
Groups: php.notes 
Request: Send a blank email to php-notes+get-209191@lists.php.net to get a copy of this message
$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()); // use this func 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. ---- Server IP: 208.43.231.9 Probable Submitter: 112.10.222.196 ---- Manual Page -- http://php.net/manual/en/function.iterator-apply.php Edit -- https://master.php.net/note/edit/121897 Del: integrated -- https://master.php.net/note/delete/121897/integrated Del: useless -- https://master.php.net/note/delete/121897/useless Del: bad code -- https://master.php.net/note/delete/121897/bad+code Del: spam -- https://master.php.net/note/delete/121897/spam Del: non-english -- https://master.php.net/note/delete/121897/non-english Del: in docs -- https://master.php.net/note/delete/121897/in+docs Del: other reasons-- https://master.php.net/note/delete/121897 Reject -- https://master.php.net/note/reject/121897 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#209191) next »