Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This class is available at: <a href="http://php.net/manual/en/arrayobject.construct.php#111192" rel="nofollow">http://php.net/manual/en/arrayobject.construct.php#111192</a></p> <pre><code>/** * @author Iltar van der Berg * @version 2.0.0 */ class RecursiveArrayObject extends ArrayObject { /** * overwrites the ArrayObject constructor for * iteration through the "array". When the item * is an array, it creates another self() instead * of an array * * @param Array $array data array */ public function __construct(Array $array) { foreach($array as $key =&gt; $value) { if(is_array($value)){ $value = new static($value); } $this-&gt;offsetSet($key, $value); } } /** * returns Array when printed (like "echo array();") * instead of an error * * @return string */ public function __ToString() { return 'Array'; } } </code></pre> <p>Usage:</p> <pre><code>$a = array( 'one' =&gt; array( 'hello','world' ), 'two' =&gt; array( 'lorem','ipsum' ) ); var_dump($a); $o = new RecursiveArrayObject($a); var_dump($o); </code></pre> <p>Yields:</p> <pre><code>array (size=2) 'one' =&gt; array (size=2) 0 =&gt; string 'hello' (length=5) 1 =&gt; string 'world' (length=5) 'two' =&gt; array (size=2) 0 =&gt; string 'lorem' (length=5) 1 =&gt; string 'ipsum' (length=5) object(RecursiveArrayObject)[1] public 'one' =&gt; object(RecursiveArrayObject)[2] string 'hello' (length=5) string 'world' (length=5) public 'two' =&gt; object(RecursiveArrayObject)[3] string 'lorem' (length=5) string 'ipsum' (length=5) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload