note 95405 deleted from function.getcwd by danbrown
| From: | danbrown@php.net | Date: | Fri, 01 Jan 2010 17:30:38 +0000 |
| Subject: | note 95405 deleted from function.getcwd by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164513@lists.php.net to get a copy of this message | ||
Note Submitter: george dot wooten at gmail dot com
----
It might be more expedient to use explode if you want
to preserve the (e.g.) 2nd-to-last folder name before
the function output loads. In that case, initialize an
array and save the desired folder name from the get-go:
$namedir = array(); //initialize
$pathname = getcwd() ; // path named in main script
$newpath = str_replace('\\','/',$pathname,$count) ;
$namedir = explode("/",$newpath) ; //parse subfolders
$foldername = $namedir[count($namedir)-2] ; //2nd-to-last folder
Depending on your system, it may be possible to use dirname instead of $pathname=getcwd() but if you
want to do this with local variables then the path
still needs to be exploded prior to loading the
function results:
$pathname = dirname(__FILE__) ; // also works
In my case the folder named \waterfalls\ needed to
be extracted from this string:
C:\xampp\htdocs\mydomain.com\\waterfalls\files\high.JPG