src/Type/StdTravers.php
function toArray(\Closure $filter = null, $recursive = false)
    {
        $arr = array();
        foreach($this->getIterator() as $key => $val)
        {
            if ($recursive && ( $val instanceof \Traversable || is_array($val) ) ) {
                // (A) At the end value can be empty by filter
                ## deep convert
                $val = StdTravers::of($val)->toArray($filter, $recursive);
            }

            // (B) So Filter Check Placed After Recursive Calls
            $flag = false;
            if ($filter !== null)
                $flag = $filter($val, $key);

            if ($flag) continue;


            if (! \Poirot\Std\isStringify($key) )
                ## some poirot Traversable is able to handle objects as key
                $key = \Poirot\Std\flatten($key);

            $arr[(string) $key] = $val;
        }

        return $arr;
    }
function toArray(\Closure $filter = null, $recursive = false)
    {
        $arr = array();
        foreach($this->getIterator() as $key => $val)
        {
            if ($recursive && ( $val instanceof \Traversable || is_array($val) ) ) {
                // (A) At the end value can be empty by filter
                ## deep convert
                $val = StdTravers::of($val)->toArray($filter, $recursive);
            }

            // (B) So Filter Check Placed After Recursive Calls
            $flag = false;
            if ($filter !== null)
                $flag = $filter($val, $key);

            if ($flag) continue;


            if (! \Poirot\Std\isStringify($key) )
                ## some poirot Traversable is able to handle objects as key
                $key = \Poirot\Std\flatten($key);

            $arr[(string) $key] = $val;
        }

        return $arr;
    }
function toArray ( \ Closure $ filter = null , $ recursive = false ) { $ arr = array ( ) ; foreach ( $ this -> getIterator ( ) as $ key => $ val ) { if ( $ recursive && ( $ val instanceof \ Traversable || is_array ( $ val ) ) ) { // (A) At the end value can be empty by filter ## deep convert $ val = StdTravers :: of ( $ val ) -> toArray ( $ filter , $ recursive ) ; } // (B) So Filter Check Placed After Recursive Calls $ flag = false ; if ( $ filter !== null ) $ flag = $ filter ( $ val , $ key ) ; if ( $ flag ) continue ; if ( ! \ Poirot \ Std \ isStringify ( $ key ) ) ## some poirot Traversable is able to handle objects as key $ key = \ Poirot \ Std \ flatten ( $ key ) ; $ arr [ ( string ) $ key ] = $ val ; } return $ arr ; }
Convert Iterator To An Array

filter:
// return true mean not present to output array
bool function(&$val, &$key = null);

@param \Closure|null $filter
@param bool          $recursive     Recursively convert values that can be iterated

@return array
Convert Iterator To An Array