Reputation: 1435
dirname($_SERVER['PHP_SELF'])
returns in my case : /blabla/test
I am trying a preg_replace so to remove /blabla/.
I do this :
$dossier = preg_replace('/^\/[0-9a_z]\/$/','',dirname($_SERVER['PHP_SELF']));
what I hoped to be doing was : "find anything that starts with / and ends with / and has 0-9a-z in between. But this is not how to do this.
Thanks
Upvotes: 0
Views: 522
Reputation: 2008
Putting that dollar sign in there is throwing off the regex. I believe this is what you're looking for. Let me know if that doesn't work.
$dossier = preg_replace('/^\/[0-9a-z]*\//', '', dirname($_SERVER('PHP_SELF']));
Upvotes: 1
Reputation: 350079
Three issues:
a-z
, not an underscore+
$
So this will do it:
/^\/[0-9a-z]+\//'
Upvotes: 0