我有一个WordPress数据库,其中包含一些来自SoundCloud的嵌入式iframe。我希望将这些iframe替换为某种简码(shortcode)。我甚至创建了一个简码,它的效果非常好。
问题是我有一个旧的数据库,大约有2000篇文章已经嵌入代码。我想编写一段代码,以便用简码替换iframe。
以下是我正在使用的代码,用于从内容中查找URL,但它总是返回空白。
问题是我有一个旧的数据库,大约有2000篇文章已经嵌入代码。我想编写一段代码,以便用简码替换iframe。
以下是我正在使用的代码,用于从内容中查找URL,但它总是返回空白。
$string = 'Think Kavinsky meets Futurecop! meets your favorite 80s TV show theme song and you might be pretty close to Swedish producer Johan Bengtsson\'s retro project, <a href="https://soundcloud.com/daataa"><strong>Mitch Murder</strong></a>. Title track, "The Touch," is genuinely lighthearted and fun, crossing over from 80s synth work into a bit of French Touch influence; also including a big time guitar solo straight out of your dad\'s record collection. B-side "Race Day" could very easily be the soundtrack to a video montage of all of your favorite beach scenes from every 80s movie you\'ve ever watched, or as the PR put it, "quite possibly a contender to be the title screen music to a Wave Race 64 sequel." Sounds awesome to me. Also included in this package out today on <a href="https://soundcloud.com/maddecent/">Mad Decent</a>\'s Jeffree\'s sub-label are two remixes of the A-side from Lifelike and Nite Sprite. Download below.
<iframe src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F8087281&color=000000&auto_play=false&show_artwork=true" frameborder="no" scrolling="no" width="100%" height="350"></iframe>';
preg_match("/url=(.*?)/", $string, $matches);
print_r($matches);
以上代码无法运行,我不太熟悉正则表达式,如果有人能找出问题所在,那就太好了。而且如果有人能指导我正确的处理方法,那就更好了。