我想問一下能否獲得某個特定關鍵字之間的字符串?例如,我有2句這樣的:PHP獲取特定字詞內的一些字符串
I will go to #new bathroom and wash the car#
結果:bathroom and wash the car
Someone need an #new icebreaker# to hold that problem
結果:icebreaker
我想使病情得到#new #
任何想法如何之間的所有單詞創造這個?
我迄今爲止代碼:
<?php
$sentence = "I will go to #new bathroom and wash the car#";
$start = strpos($sentence, "#new");
//$end = strpos($sentence, "#");
$end = 20; //because my strpos still wrong, I define a static number
$new = substr($sentence, $start, $end);
echo $new;
?>
我的問題是我無法找到一個方法來追逐最後的主題標籤
http://regular-expressions.info – deceze
檢查https://stackoverflow.com/questions/5127322/output-text-in-between-two-words?rq=1 – Saty
@Saty謝謝! –