YuriDan
3/28/2014 - 5:59 AM

PHP — информация о файле UTF

function pathinfo_utf($path)
{

	if (strpos($path, '/') !== false)
		$basename = end(explode('/', $path));
	elseif (strpos($path, '\\') !== false)
		$basename = end(explode('\\', $path));
	else
		return false;

	if (!$basename)
		return false;

	$dirname = substr($path, 0,
		strlen($path) - strlen($basename) - 1);

	if (strpos($basename, '.') !== false) {
		$extension = end(explode('.', $path));
		$filename = substr($basename, 0,
			strlen($basename) - strlen($extension) - 1);
	} else {
		$extension = '';
		$filename = $basename;
	}

	return array(
		'dirname' => $dirname,
		'basename' => $basename,
		'extension' => $extension,
		'filename' => $filename
	);
}
?>