title: Php Dynamically Embed YouTube Videos
body: <p>My page accepts any text in text area with no chars limit. I want to display youtube video in place of the "youtubeURL" or the direct embed code of youtube if the text data contains any of the above way.</p>
  
  <p><strong>example:</strong> If user enters following text into text area :</p>
  
  <p>"Here is video by embed code: </p>
  
  <pre><code>&lt; iframe width="420" height="315" src="https://www.youtube.com/embed/7M-jsjLB20Y" frameborder="0" allowfullscreen&gt;&lt; /iframe &gt; 
  </code></pre>
  
  <p>and here is the video by url:
  <a href="https://www.youtube.com/watch?v=7M-jsjLB20Y%22" rel="nofollow noreferrer">https://www.youtube.com/watch?v=7M-jsjLB20Y"</a></p>
  
  <p>so post data will show in page like :</p>
  
  <p><br>
  Here is video by embed code:<br>
  <strong>"DISPLAY YOUTUBE VIDEO HERE"</strong> <br>
  and here is the video by url:<br>
  <strong>"DISPLAY YOUTUBE VIDEO HERE"</strong><br></p>
  
  <p>In short I want help to code Php page which accepts both way of youtube video embedding and find it from the text data then process it. It would be great help if anybody can give me idea which works with both way. </p>