Get the fileName property of a PharFileInfo object
I have a PharData object and I want to get an array of file names inside.
foreach($PharData as $object){
print_r($object);
}
returns
PharFileInfo Object
(
[username: SplFileInfo: private] => phar: // C: /.../arch.tar/pmnt.csv
[filename: SplFileInfo: private] => pmnt.csv
)
...
How do I get the fileName property? Tried $ object-> filename but it doesn't talk about this property. "Echo $ object" gives pathName, but I don't want to parse it for filename if there is an easier way
+3
source to share
2 answers
Use this code
$info = new SplFileInfo('phar://C:/.../arch.tar/pmnt.csv');//your path to the file.
var_dump($info->getFilename());
Splfileinfo link
0
source to share