替換div內容,我發佈了一個關於「Hom使用PHP函數更改DIV ID」的問題,並且有人用正則表達式找到了正確的答案。昨天,我用PHP
問題是,我想用這個答案適用於其他相同問題的方法。
但是,因爲我在正則表達式上很糟糕,所以我不能。
所以問題是,我上載有FCKEditor的一些視頻,並把視頻腳本在我的數據庫,結果是這樣的:
<div id="player959093-parent" style="text-align: center;float: left;">
<div style="border-style: none; height: 160px; width: 270px; overflow: hidden; background-color: rgb(220, 220, 220); background-image: url(http://localhost/fckeditor/editor/plugins/flvPlayer/flvPlayer.gif); background-repeat:no-repeat; background-position:center;"><script src="http://localhost/fckeditor/editor/plugins/flvPlayer/swfobject.js" type="text/javascript"></script>
<div id="player959093"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.
<div id="player959093-config" style="display: none;visibility: hidden;width: 0px;height:0px;overflow: hidden;">url=/editeur/images/flash/FOO.flv width=270 height=160 loop=false play=false downloadable=false fullscreen=true displayNavigation=true displayDigits=true align=left dispPlaylist=none playlistThumbs=false</div>
</div>
<script type="text/javascript">
var s1 = new SWFObject("http://localhost/editeur/javascript/fckeditor/editor/plugins/flvPlayer/mediaplayer.swf","single","270","160","7");
s1.addVariable("width","270");
s1.addVariable("height","160");
s1.addVariable("autostart","false");
s1.addVariable("file","/editeur/images/flash/FOO.flv");
s1.addVariable("repeat","false");
s1.addVariable("image","");
s1.addVariable("showdownload","false");
s1.addVariable("link","/editeur/images/flash/FOO.flv");
s1.addParam("allowfullscreen","true");
s1.addVariable("showdigits","true");
s1.addVariable("shownavigation","true");
s1.addVariable("logo","");
s1.write("player959093");
</script></div>
</div>
當我在我的PHP頁面一次呼應此內容,它的工作原理大。不止一次,視頻不會出現。由於唯一ID,這是明顯的 。 正如你所看到的,內容具有這些ID:
div id="player959093-parent"
div id="player959093"
div id="player959093-config
s1.write("player959093");
所以我的問題是:有沒有可以替換的字符串「player959093」或一些其他 串來解決顯示問題串連函數嗎?
非常感謝, 關心。
感謝這個正則表達式! – Zakaria 2010-03-19 15:24:20