12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace file;
- class PathHelper
- {
-
- public static function getFilename($path)
- {
- return pathinfo($path)['basename'];
- }
-
- public static function getExt($path)
- {
- return pathinfo($path)['extension'];
- }
-
- public static function getDir($path)
- {
-
- return dirname($path);
- }
-
- public static function getParentDir($path, $separator = DS)
- {
- $path = deleteEndDS($path, $separator);
- $res = explode($separator, $path);
- if (is_array($res)) {
- $end = end($res);
-
- $endres = preg_replace("~$end(?!.*$end)~", '', $path);
- return $separator == $endres ? $endres : deleteEndDS($endres, $separator);
- }
- return $res;
- }
- }
|