Run
Run

Reputation: 57176

how to return the file's path without the file's basename?

I have a long path for a file, for instance,

http://www.mysite.com/local/views/templates/home.php

and I use basename() to return the file itself only,

<?php echo basename($file);?>

But how can I return the file's path without the file's basename like the line below?

http://www.mysite.com/local/views/templates/

Upvotes: 4

Views: 2729

Answers (1)

Jon
Jon

Reputation: 437336

You are looking for dirname (although it doesn't leave a trailing slash).

See it in action.

Upvotes: 4

Related Questions