我有一個字符串,裏面有哈希標記,我試圖將標記拉出來我想我很近但是得到相同的結果如何從字符串中抽取以哈希標記(#)開頭的單詞到數組
$string = "this is #a string with #some sweet #hash tags";
preg_match_all('/(?!\b)(#\w+\b)/',$string,$matches);
print_r($matches);
這將產生
Array (
[0] => Array (
[0] => "#a"
[1] => "#some"
[2] => "#hash"
)
[1] => Array (
[0] => "#a"
[1] => "#some"
[2] => "#hash"
)
)
我只想一個數組與哈希標籤開始每個字一個多維數組。
非常感謝你。 。它的工作! – Nikz
@Nikz非常歡迎... :)高興地幫助 –
如何使用起始關鍵字提取所有世界? –