處理後取代它,我有這樣的類似如何訪問字符串的特定部分,並在PHP
$text_string = 'Every thing must be done in time. So,It is not a good thing to be
so late. What are the Rules of This Process are prominent in this
video [VIDEO]http://www.youtube.com/watch?v=yseAuiSl[/VIDEO]. So,
It will be more sensible if you watch a tutorial here
[VIDEO]http://www.dailymotion.com/video/xyxmu6_underwater[/VIDEO]
It is much more explanatory. These are the Rules of Thumb.'
我需要得到每個[VIDEO] .... [/VIDEO]
,然後將它傳遞給函數的字符串(我創建我自己該功能),將其轉換成根據其嵌入代碼例如
[VIDEO]http://www.youtube.com/watch?v=yseAuiSl[/VIDEO]
將被轉換爲
<iframe width="680" height="450" src="http://www.youtube.com/embed/yseAuiSl"
frameborder="0" allowfullscreen></iframe>
然後,我需要用其嵌入代碼替換[VIDEO] .... [/VIDEO]
。那麼,我如何循環遍歷整個字符串並逐個獲取各個[VIDEO] ... [/VIDEO]
標記,並在處理後用它的嵌入代碼替換它?
'preg_replace();'? – egig
@Charlie僅用於替換,但首先我需要獲取整個VIDEO標籤,通過函數處理它,然後將其替換爲輸出。那麼,如何從字符串中獲取每個VIDEO標籤? –
使用'preg_match()' - >處理 - >'preg_replace()'。祝你好運 ! – egig