<?php $path = "/path/other/file.txt"; echo basename($path ); // выводит "file.txt" echo basename($path, '.txt'); // выводит "file" ?>