Php, is there an array to iterator converter?

John Smith

its good that there is iterator to array http://php.net/manual/en/function.iterator-to-array.php but is there anything to do it reversed?

JustOnUnderMillions

Yes, if reversed means just make an Iterator from a given Array.

$array = array(
  'a' => 1,
  2 => new stdClass,
  3 => array('subArrayStuff'=>'value')
);

$iterator = new ArrayObject($array);

$arrayAgain = iterator_to_array($iterator);

Try it.

http://php.net/manual/en/class.arrayobject.php

Please read also Difference between ArrayIterator, ArrayObject and Array in PHP.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

TypeScript and Iterator: Type 'IterableIterator<T>' is not an array type

From Java

Transforming a Javascript iterator into an array

From Dev

Accessing element of an array with iterator instead of position in Swift

From Dev

PHP - Recursive Multidimension Array iterator

From Dev

Treat a PHP class that implements Iterator as an array

From Dev

Currency Converter Using PHP

From Dev

Referencing Auto Array Iterator in function

From Dev

s:iterator with collection of Object array

From Dev

Java Array Iterator

From Dev

in javascript, create Array from an iterator

From Dev

LINQ .Any() iterator for 2D Array - [,]

From Dev

Reading from InputStream as an Iterator[Byte] or Array[Byte]

From Dev

PHP Morse code converter

From Dev

Comparing iterator with (fixed sized) array

From Dev

Overriding Iterator in circular array

From Dev

Destructure Array using entries and iterator

From Dev

Return Iterator of an array wrapped in an Option

From Dev

Treat a PHP class that implements Iterator as an array

From Dev

Referencing Auto Array Iterator in function

From Dev

Java Array Iterator

From Dev

Standard Java varargs converter to array

From Dev

Overriding Iterator in circular array

From Dev

Php, is there an array to iterator converter?

From Dev

Currency converter in html+php

From Dev

Iterator with Static Array Member variable

From Dev

Is it possible to use iterator in C array?

From Dev

PHP file/image converter

From Dev

PHP Iterator interface: current() returns underlying array instead of first value

From Dev

PHP file size converter