Convert SplFileInfo to String

class, object, php

Solution

`$value` is instance of SplFileInfo, if u need filename push `$key` or `$value->__toString()` to `$files`

Problem

I'm using a DirectoryIterator to get a folder's contents, and it works just fine : ``` $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . $this->certificate), RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $key => $value) { array_push($files, $value); } unset($value); ``` But my `$files` result when printed it isn't a string but a STD Class. How could I convert that output as a string ( in case there's only one file ) or to an array ? EDIT : This would be the result I get : ``` { [0]=> object(SplFileInfo)#5 (2) { ["pathName":"SplFileInfo":private]=> string(101) "C:\Users\rgr\Apache\htdocs\Roland Groza [ 3.0 ]\class\mongohq/certificate\GTECyberTrustGlobalRoot.crt" ["fileName":"SplFileInfo":private]=> string(27) "GTECyberTrustGlobalRoot.crt" } } ```

Original source