Forum Moderators: coopster

Message Too Old, No Replies

phrase directory name

Not a PHP guru here...

         

hanuman

8:27 am on Mar 31, 2004 (gmt 0)

10+ Year Member



Not a PHP guru here...

how do i go phrasing directory name as

/www/htdocs/www/200401 to January, 2004
/www/htdocs/www/200402 to January, 2004

and so on...many thanks

mykel79

1:30 pm on Mar 31, 2004 (gmt 0)

10+ Year Member



How exactly to you want to use that? Just display it?
You could to it like this:
Let's say the directory name is in the $string variable.

$months["01"]='January';
$months["02"]='February';
$months["03"]='March';
$months["04"]='April';
$months["05"]='May';
$months["06"]='June';
$months["07"]='July';
$months["08"]='August';
$months["09"]='September';
$months["10"]='October';
$months["11"]='November';
$months["12"]='December';

$string='/www/htdocs/www/200401';
$string=str_replace('/www/htdocs/www/','',$string);
$year=substr($string,0,4);
$month=$months[substr($string,4)];
echo $month,', ',$year;

This method is of course very primitive and won't work if the directory is named even slightly differently. For a more universal approach you will have to use regular expressions.

ergophobe

4:52 pm on Mar 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Frankly, I wouldn't use those path names. The spaces in them may make life difficult for you if you decide to host in a Unix environment.

See:

[cmgm.stanford.edu...]

[lehigh.edu...]

I don't know about using commas in path names.

Tom