If you need to determine the base element from a URL or path of a file then this snippet can help you.
<?php
/*
Source: http://www.bitrepository.com/
*/
function Get_Base_From_File($file)
{
$find = '/';
$after_find = substr(strrchr($file, $find), 1);
$strlen_str = strlen($after_find);
$result = substr($file, 0, -$strlen_str);
return $result;
}
$file = 'http://www.domain.com/path/to/file.zip';
$base = Get_Base_From_File($file);
// Output: http://www.domain.com/path/to/
echo $base;
?>