iterator_to_array

(PHP 5 >= 5.1.0, PHP 7)

iterator_to_array锟斤拷锟斤拷锟斤拷锟斤拷锟叫碉拷元锟截匡拷锟斤拷锟斤拷锟斤拷锟斤拷

说锟斤拷

iterator_to_array ( Traversable $iterator [, bool $use_keys = true ] ) : array

锟斤拷锟斤拷锟斤拷锟斤拷锟叫碉拷元锟截匡拷锟斤拷锟斤拷锟斤拷锟介。

锟斤拷锟斤拷

iterator

锟斤拷锟斤拷锟斤拷锟侥碉拷锟斤拷锟斤拷锟斤拷

use_keys

锟角凤拷使锟矫碉拷锟斤拷锟斤拷元锟截硷拷锟斤拷为锟斤拷锟斤拷锟斤拷

锟斤拷锟斤拷值

一锟斤拷锟斤拷锟介,锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫碉拷元锟截★拷

锟斤拷锟斤拷锟斤拷志

锟芥本 说锟斤拷
5.2.1 锟斤拷锟斤拷锟� use_keys 锟斤拷锟斤拷锟斤拷

锟斤拷锟斤拷

Example #1 iterator_to_array() example

<?php
$iterator 
= new ArrayIterator(array('recipe'=>'pancakes''egg''milk''flour'));
var_dump(iterator_to_array($iteratortrue));
var_dump(iterator_to_array($iteratorfalse));
?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

array(4) {
  ["recipe"]=>
  string(8) "pancakes"
  [0]=>
  string(3) "egg"
  [1]=>
  string(4) "milk"
  [2]=>
  string(5) "flour"
}
array(4) {
  [0]=>
  string(8) "pancakes"
  [1]=>
  string(3) "egg"
  [2]=>
  string(4) "milk"
  [3]=>
  string(5) "flour"
}