Reputation: 47
I have this string generated by wordpress functions in php
D:\wamp\www\myProject/wp-content/uploads/2015/11
And I want to delete the part of
D:\wamp\www\myProject/
And only have as result using preg_replace()
uploads/2015/11
I know that this is a silly question but I'm new with wordpress and a little bit in php.
Cheers!
Upvotes: 0
Views: 323
Reputation: 602
Use this regular expression:
$path = "D:\wamp\www\myProject/wp-content/uploads/2015/11";
$the_desired_part = preg_replace("/.+?\/(wp-content.+?)/", "", $path);
echo $the_desired_part;
Upvotes: -1
Reputation: 1058
You could use str_replace()
for this.
$input = "D:\wamp\www\myProject/wp-content/uploads/2015/11";
$output = str_replace("D:\wamp\www\myProject/", "", $input);
str_replace();
syntax: http://php.net/manual/en/function.str-replace.php
Upvotes: 2