Connecting Tech Pros Worldwide Forums | Help | Site Map

Find the name of the current folder

Krustov
Guest
 
Posts: n/a
#1: Nov 10 '05
For use in a install.php

What would be the best way to do it .


Kim André Akerĝ
Guest
 
Posts: n/a
#2: Nov 10 '05

re: Find the name of the current folder


Krustov wrote:
[color=blue]
> For use in a install.php
>
> What would be the best way to do it .[/color]

Probably with getcwd().
http://php.net/getcwd

--
Kim André Akerĝ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Krustov
Guest
 
Posts: n/a
#3: Nov 10 '05

re: Find the name of the current folder


<comp.lang.php , Kim André Akerĝ , kimandre@NOSPAMbetadome.com>
<3theu2Ft4048U1@individual.net>
<10 Nov 2005 17:39:14 GMT>
[color=blue][color=green]
> > For use in a install.php
> >
> > What would be the best way to do it .[/color]
>
> Probably with getcwd().
> http://php.net/getcwd
> [/color]

Sounds good to me - thank you .
Krustov
Guest
 
Posts: n/a
#4: Nov 10 '05

re: Find the name of the current folder


<comp.lang.php , Krustov , krusty@krustov.co.uk.INVALID>
<MPG.1ddd991e1a81c0c498a68a@no-cancel.newsreader.com>
<Thu, 10 Nov 2005 17:52:02 -0000>
[color=blue][color=green][color=darkred]
> > > For use in a install.php
> > >
> > > What would be the best way to do it .[/color]
> >
> > Probably with getcwd().
> > http://php.net/getcwd
> >[/color]
>
> Sounds good to me - thank you .
>[/color]

As I only need/want the last folder name and as i'm still a bit of a php
newbie is there any better way of doing it than the following .

(havent tried it on the webspace yet but assume it works just as well)

<?php

$junk=getcwd();
print $junk;

$pass="0"; $long=0;

$tv=strlen($junk); $dvd=$tv-1;

while ($pass=="0")
{
$vhs=substr($junk,$dvd,1);
if ($vhs==chr(47)) {$pass=1;}
if ($vhs==chr(92)) {$pass=1;}
$long=$long+1; $dvd=$dvd-1;
}

$vhs=substr($junk,$dvd+2,$long-1);
print "<br><br>";
print "$vhs";

?>
Janwillem Borleffs
Guest
 
Posts: n/a
#5: Nov 10 '05

re: Find the name of the current folder


Krustov wrote:[color=blue]
> As I only need/want the last folder name and as i'm still a bit of a
> php newbie is there any better way of doing it than the following .
>[/color]

print basename(getcwd());


JW


Krustov
Guest
 
Posts: n/a
#6: Nov 10 '05

re: Find the name of the current folder


<comp.lang.php , Janwillem Borleffs , jw@jwscripts.com>
<4373b613$0$67571$dbd4d001@news.euronet.nl>
<Thu, 10 Nov 2005 22:05:28 +0100>
[color=blue][color=green]
> > As I only need/want the last folder name and as i'm still a bit of a
> > php newbie is there any better way of doing it than the following .
> >[/color]
>
> print basename(getcwd());
>[/color]

Typical and my own fault for not being clear in the OP .
Closed Thread