Posted By

flatearthcomms on 05/10/09


Tagged


Versions (?)

STRIP CURRENT URL OF ARBITRARY FOLDERS AND NAME ANCHOR


 / Published in: PHP
 

Useful for comparing file path when developing on different test sites, leaves just file name, also strips named anchors from end

  1. // REPLACE FOLDERS WITH NOTHING
  2. // str_replace(find_this, replace_with_this, string_to_search );
  3. // This strips folder names from the path
  4. $me = str_replace("/acme/project/090331/", "", $_SERVER["REQUEST_URI"] );
  5. //$me = ereg_replace ( find_this, replace_with_this, string_to_search );
  6. // This strips #anything from end of url
  7. $me = ereg_replace ( "#(.*)", "", $me );

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Vordreller on May 12, 2009

Be carefull when PHP6 hits, because then this won't work anymore.

The "ereg" regular expression library will be removed from the main build and turned into an extension. The "preg" regex library is recommended.

You need to login to post a comment.