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
Post a Comment