[thelist] Getting path minus document root using PHP

misterhaan misterhaan at track7.org
Thu Dec 13 14:54:14 CST 2007

I would use something like this:

if(substr($string, 0, strlen($_SERVER['DOCUMENT_ROOT'])) == 
  $string = substr($string, strlen($_SERVER['DOCUMENT_ROOT']));

That says if $string starts with the doc root, drop the beginning 
characters for the length of the doc root.

More information about the thelist mailing list