PHP: take a path from site root given an absolute path

18 views Asked by At

Maybe a dumb question: given a full path like:

C:/wamp/www/acme/archivio/subfolder/C00005/FATCLI/2014-V00011.pdf

and given that site root is acme, how can I get the part:

/archivio/subfolder/C00005/FATCLI/2014-V00011.pdf

in the easiest way?

1

There are 1 answers

0
Sougata Bose On BEST ANSWER

You can use explode -

$path = 'C:/wamp/www/acme/archivio/subfolder/C00005/FATCLI/2014-V00011.pdf';

$paths = explode('acme', $path);

echo $paths[1];

explode()

You can variable also -

$root = 'acme';
$paths = explode($root, $path);