Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>New Complete Solution:</h2> <pre><code>&lt;?php //your bad code which you want to sanitize $BadCode = '&lt;object width="640" height="385"&gt; &lt;param name="movie" value="http://www.youtube.com/v/TvJsRX9SKUo?fs=1&amp;hl=it_IT"&gt;&lt;/param&gt; &lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt; &lt;embed src="http://www.youtube.com/v/TvJsRX9SKUo?fs=1&amp;hl=it_IT" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"&gt;&lt;/embed&gt; &lt;/object&gt;'; //Get Youtube Video ID preg_match('#(?&lt;=youtube\.com/v/)\w+#', $BadCode, $matches); $VideoID = $matches[0]; //New Correct and consistent embed code template. Create whatever consistent template you want. Then all your videos will follow this template. Change the place where video-id appears as [VIDEOID] $template = '&lt;object type="application/x-shockwave-flash" style="width:450px; height:366px;" data="http://www.youtube.com/v/[VIDEOID]?showsearch=0&amp;amp;fs=1"&gt; &lt;param name="movie" value="http://www.youtube.com/v/[VIDEOID]?showsearch=0&amp;amp;fs=1" /&gt;&lt;param name="allowFullScreen" value="true" /&gt; &lt;/object&gt;'; //Insert our VideoID into this template. $GoodCode = str_replace('[VIDEOID]', $VideoID, $template); //Display code for testing echo $GoodCode; //Update your database table (please change variables yourself) //mysql_query("update tablename set YoutubeCode = '".$GoodCode."' where ID={$ID}"); ?&gt; </code></pre> <h2>Old Summarized Answer:</h2> <p>[Regex for extracting video ID]. After getting video ID, you have the video ID. Use this ID to generate a clean consistent code for all your videos. Then, update the database.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload