简单的查找和替换

I am trying to make sure all YouTube embeds have two attributes from the API. I'm trying to find and replace all of:

rel=0&

with

rel0&theme=light&autohide=1&

So far, I've got this, from an online tester, which apparently finds rel=0&:

preg_replace("/(.*), (.*)/", "$0 --> $2 $1", $input_lines); ()

However, I am unsure how utilise the above to replace the above code with rel0&theme=light&autohide=1&

Any help would be great.

You could use:

str_replace("rel=0&", "rel0&theme=light&autohide=1&", $input_lines);

If you have &, you can do this:

str_replace(array('rel=0&', '&'), array('rel0&theme=light&autohide=1&', '&') ,$input_lines);

You can just use str_replace:

str_replace('rel=0&','rel0&theme=light&autohide=1&',$input_lines)