Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Get only a part of the full path

Tags:

string

path

php

I would like to know how can I subtract only a part of the full path:

I get the full path of the current folder:

$dbc_root = getcwd(); // That will return let's say "/home/USER/public_html/test2"

I want to select only "/public_html/test2"

How can I do it? Thanks!

like image 260
Adrian Avatar asked Jan 23 '23 11:01

Adrian


1 Answers

I think you should check the path related methods:

pathinfo() - Returns information about a file path
dirname() - Returns directory name component of path
basename() - Returns filename component of path

You should be able to find a solution with one of these.

like image 113
Andreas Avatar answered Feb 02 '23 22:02

Andreas