<iframe>
WordPress ブログの Youtube を参照するタグを thisに置き換えようとしています[youtube id='THEYOUTUBEID' width='600' height='350']
。私はシンプルな HTML DOM パーサーを利用しています。私はそれを実現していますが、すべての投稿に保存されるわけではありません。
誰かが私が間違っている場所を理解するのを手伝ってくれますか?
$result = mysql_query("SELECT `post_content` FROM `wp_posts` WHERE `post_content` LIKE '<iframe%' ");
while($row = mysql_fetch_array($result)) {
$postContent = str_get_html($row["post_content"]);
foreach($postContent->find("iframe") as $iframe) {
$src = $iframe->src;
$last = substr( $src, strrpos( $src, '/' )+1 );
if (stripos($src, "youtube")) {
$neway = "[youtube id='".$last."' width='600' height='350']";
} elseif (stripos($src, "vimeo")) {
$neway = "[vimeo id='".$last."' width='600' height='350']";
}
$iframe->outertext = $neway;
}
}