iterator_to_array

Supported Versions: PHP 5 >= 5.1.0, PHP 7, PHP 8
Copy the iterator into an array
<?php iterator_to_array(Traversable|array $iterator, bool $preserve_keys = true): array
<?php     public static function glob($glob, $flags = 0)

    {

        $results = iterator_to_array(new GlobIterator($glob, $flags));



        sort($results);
<?php         $this->assertSameAfterSorting(array(

            $this->tempDir.'/base.css',

        ), iterator_to_array($iterator));

    }



    public function testIterateEscaped()
<?php         $this->assertSameAfterSorting(array(

            $this->tempDir.'/css/style*.css',

        ), iterator_to_array($iterator));

    }



    public function testIterateSpecialChars()
<?php         $this->assertSameAfterSorting(array(

            $this->tempDir.'/css/style*.css',

            $this->tempDir.'/css/style.css',

        ), iterator_to_array($iterator));

    }



    public function testIterateDoubleWildcard()
<?php             $this->tempDir.'/base.css',

            $this->tempDir.'/css/reset.css',

            $this->tempDir.'/css/style.css',

        ), iterator_to_array($iterator));

    }



    public function testIterateSingleDirectory()
<?php         $this->assertSame(array(

            $this->tempDir.'/css',

        ), iterator_to_array($iterator));

    }



    public function testIterateSingleFile()
<?php         $this->assertSame(array(

            $this->tempDir.'/css/style.css',

        ), iterator_to_array($iterator));

    }



    public function testIterateSingleFileInDirectoryWithUnreadableFiles()
<?php         $this->assertSame(array(

            $this->tempFile,

        ), iterator_to_array($iterator));

    }



    public function testWildcardMayMatchZeroCharacters()
<?php         $this->assertSameAfterSorting(array(

            $this->tempDir.'/base.css',

            $this->tempDir.'/css',

        ), iterator_to_array($iterator));

    }



    public function testDoubleWildcardMayMatchZeroCharacters()
<?php             $this->tempDir.'/css',

            $this->tempDir.'/css/reset.css',

            $this->tempDir.'/css/style.css',

        ), iterator_to_array($iterator));

    }



    public function testWildcardInRoot()
<?php             $this->tempDir.'/base.css',

            $this->tempDir.'/css',

            $this->tempDir.'/js',

        ), iterator_to_array($iterator));

    }



    public function testDoubleWildcardInRoot()
<?php             $this->tempDir.'/css/style.cxs',

            $this->tempDir.'/js',

            $this->tempDir.'/js/script.js',

        ), iterator_to_array($iterator));

    }



    public function testNoMatches()
<?php     {

        $iterator = new GlobIterator($this->tempDir.'/foo*');



        $this->assertSame(array(), iterator_to_array($iterator));

    }



    public function testNonExistingBaseDirectory()
<?php     {

        $iterator = new GlobIterator($this->tempDir.'/foo/*');



        $this->assertSame(array(), iterator_to_array($iterator));

    }
<?php             $this->tempDir.'/base.css' => $this->tempDir.'/base.css',

            $this->tempDir.'/css' => $this->tempDir.'/css',

            $this->tempDir.'/js' => $this->tempDir.'/js',

        ), iterator_to_array($iterator));

    }



    public function testIterateSkipDots()