phpDev
phpDev

Reputation: 39

how to start string from specific character and remove unwanted characters

I have URL of file which looks like this

movieImages/1`updateCategory.PNG

it should look like this

updateCategory.PNG

Upvotes: 0

Views: 46

Answers (2)

user4185677
user4185677

Reputation:

you can use like this, simple

$string = 'movieImages/1`updateCategory.PNG';
$ser = 'movieImages/1`';
$trimmed = str_replace($ser, '', $string);
echo $trimmed;

output will be updateCategory.PNG

Upvotes: 1

Hanky Panky
Hanky Panky

Reputation: 46910

Find the position of unwanted character and then pick up the substring after that position.

$str="movieImages/1`updateCategory.PNG";
$unwanted="`";
echo substr($str,strpos($str,$unwanted)+1);

Output

updateCategory.PNG

Fiddle

That is if the string can vary in structure and size. If the first part will always remain same you can simply remove the unwanted stuff using str_replace.

echo str_replace('movieImages/1`','',$str);

Upvotes: 1

Related Questions