JBZoo\Utils\FS::stripExt PHP Method

stripExt() public static method

Strip off the extension if it exists.
public static stripExt ( string $path ) : string
$path string
return string
    public static function stripExt($path)
    {
        $reg = '/\\.' . preg_quote(self::ext($path)) . '$/';
        $path = preg_replace($reg, '', $path);
        return $path;
    }

Usage Example

コード例 #1
0
ファイル: FileSystemTest.php プロジェクト: jbzoo/utils
 public function testStripExt()
 {
     isSame('image', FS::stripExt('image.png'));
     isSame('image.jpg', FS::stripExt('image.jpg.png'));
     isSame('/file/path/image.jpg', FS::stripExt('/file/path/image.jpg.png'));
 }