How to get the file path without the file name in php? -


for example $_server['http_host'] . $_server['request_uri'] output:

example.com/foldername/subfolder/controller/index.php 

i want end example.com/foldername/subfolder/controller/

thanks..

check out http://php.net/manual/en/function.pathinfo.php

<?php $path_parts = pathinfo('/www/htdocs/inc/lib.inc.php');  echo $path_parts['dirname'], "\n"; echo $path_parts['basename'], "\n"; echo $path_parts['extension'], "\n"; echo $path_parts['filename'], "\n"; // since php 5.2.0 ?> 

the output be

/www/htdocs/inc lib.inc.php php lib.inc 

so, in short, use $path_parts['dirname'].


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -