在php中删除url字符串的最后一部分

I have a url string like this:

http://example.com/sfm?dir=uploads/sfm/root/folder5/file.zip

echo $_GET['extract'] outputs this: uploads/sfm/root/folder5/file.zip How can i strip the last file.zip so that

echo $_GET['extract'] outputs this: uploads/sfm/root/folder5/

Just use dirname - Returns a parent directory's path

echo dirname($_GET['extract'])."/";

use below code :

$String = $_GET['extract'];
$Words = explode('/', $String);
echo end($Words );

Maybe this works:

echo substr((string)$_GET['extract'],26);

Try:

$url = "uploads/sfm/root/folder5/file.zip";
$urlArr= explode("/",$url);
array_pop($urlArr);
echo implode("/",$urlArr);

try this

<?php

 $ss ="uploads/sfm/root/folder5/file.zip";

 $vv  = explode('/',$ss);

array_pop($vv);

$mm =implode('/',$vv);
print_r($mm);

 ?>