php字符串替换不起作用

I am running a code which takes a youtube url as input and i am using str_replace on it.

$title = str_replace('watch?v=', 'embed/', $title);

but the replacement just wont happen. I keep getting the same string back.

The youtube url im using as of now is http://www.youtube.com/watch?v=iwQx9gw2NfM

what mistake am I making ? The the serch string is CLEARLY present in the url but it wont get replaced.

Or is there a better way to do this ?

EDIT: The code works fine... I was trying to replace the wrong variable

This code works fine:

$title = "http://www.youtube.com/watch?v=iwQx9gw2NfM";

$title = str_replace('watch?v=', 'embed/', $title);

echo $title;  //=> http://www.youtube.com/embed/iwQx9gw2NfM

See it work here on tehplayground

You must have another mistake in your code. Please paste your context code for additional help.