# 问题内容:

I need to remove two parts of a your tube url and replace them

watch?v= needs to be /embed/
and &feature=youtu.be needs to just be removed.

Previously I had a stip replace which worked fine on Iphones
this code was

          <?php
$url = get_post_meta( get_the_ID(), 'wpcf-item-video', true );$my_var = '/embed/';
$url = str_replace("watch?v=",$my_var, $url ); ?> <iframe src="<?php echo$url ?>?&theme=dark&autoplay=1&keyboard=1&autohide=1" height="300px" frameborder="0" gesture="media" allowfullscreen=""><style> .ytp-title{display:none;}</style></iframe>


However then I found I also need to remove the &feature=youtu.be so I did this

     <?php
$phrase = get_post_meta( get_the_ID(), 'wpcf-item-video', true );$youtube = ["watch?v=", "&feature=youtu.be"];
$replaced = ["/embed/", ""];$newPhrase = str_replace($youtube,$replaced, $phrase); ?> <iframe src="<?php echo$newPhrase ?>?&theme=dark&autoplay=1&keyboard=1&autohide=1" height="300px" frameborder="0" gesture="media" allowfullscreen=""><style> .ytp-title{display:none;}</style></iframe>


However, my latest code does not work. Can anyone explain why please?

Is there a better way of doing this?

Thanks

## 问题评论:

does not work is not usefull. What doesn’t work? What is the input string? What do you expect? What do you get? Please, edit your question and add these informations

## 原文地址：

https://stackoverflow.com/questions/47744495/why-is-this-string-replace-not-working-on-ios

0