Stripping parts of a directory path using php
I am looking to strip away a part of the following url yet have no
experience with regex or if that's even what I would use.
I have this url:
/var/www/wordpress/wp-content/themes/Aisis-Framework/CoreTheme/AdminPanel/Template/Form/Update.php
I would like to strip away everything to form:
CoreTheme/AdminPanel/Template/Form/Update.php
Is there an easy way to do this, and one that is done such that the amount
of content before "CoreTheme" could be x characters long, where x is any
number.
It should also not match on the word CoreTheme as it might be any name, it
should also not match on Aisis-Framework as that could also be any name...
how ever it is safe to assume that anything after CoreTheme is static. The
above string will be turned into, using string replace:
CoreTheme_AdminPanel_Template_Form_Update.php
As I have done in this piece of code:
$class_name = str_replace('/', '_', $path . $name);
where path is, in my solution,
CoreTheme/AdminPanel/Template/Form/Update.php and $name is Update
No comments:
Post a Comment