note 87549 added to function.iterator-to-array

From: Date: Wed, 10 Dec 2008 06:42:37 +0000
Subject: note 87549 added to function.iterator-to-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-147976@lists.php.net to get a copy of this message
Using the boolean param : <?php $first = new ArrayIterator( array('k1' => 'a' , 'k2' => 'b', 'k3' => 'c', 'k4' => 'd') ); $second = new ArrayIterator( array( 'k1' => 'X', 'k2' => 'Y', 'Z' ) ); $combinedIterator= new AppendIterator(); $combinedIterator->append( $first ); $combinedIterator->append( $second ); var_dump( iterator_to_array($combinedIterator, false) ); ?> will output : array(7) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" [4]=> string(1) "X" [5]=> string(1) "Y" [6]=> string(1) "Z" } <?php var_dump( iterator_to_array($combinedIterator, true) ); ?> will output (since keys would merge) : array(4) { [0]=> string(1) "X" [1]=> string(1) "Y" [2]=> string(1) "Z" [3]=> string(1) "d" } ---- Server IP: 66.207.199.35 Probable Submitter: 216.252.73.25 ---- Manual Page -- http://www.php.net/manual/en/function.iterator-to-array.php Edit -- https://master.php.net/note/edit/87549 Del: integrated -- https://master.php.net/note/delete/87549/integrated Del: useless -- https://master.php.net/note/delete/87549/useless Del: bad code -- https://master.php.net/note/delete/87549/bad+code Del: spam -- https://master.php.net/note/delete/87549/spam Del: non-english -- https://master.php.net/note/delete/87549/non-english Del: in docs -- https://master.php.net/note/delete/87549/in+docs Del: other reasons-- https://master.php.net/note/delete/87549 Reject -- https://master.php.net/note/reject/87549 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#147976) next »