<?php
/**
* @link http://www.php.net/manual/en/splfileinfo.getfilename.php
*/
$paths = array(
'/path/to/',
'http://example.com/path/to/',
'http://example.com/path/' ,
'http://example.com/' ,
'http://' ,
'http:/',
);
foreach ($paths as $path) {
$info = new SplFileInfo($path);
printf(
"%' -32s: %' -32s %' -12s %' -12s\n", $path, $info->getPathname()
, $info->getBasename(), $info->getFilename()
);
printf(
"%' -32s %' -32s %' -12s", '', dirname($path), basename($path)
);
echo "\n";
}
preferences:
48.44 ms | 402 KiB | 5 Q