我有一個像下面一些代碼,我使用正則表達式來拉某些內容出:PHP正則表達式第二次數
內容
[vc_row][vc_column width="1/1"][vc_column_text]
[dt_divider style="thin"/]
size 18" x 18"
[dt_divider style="thin"/]
£70
[/vc_column_text]
我已經使用下列以獲得大小:
preg_match_all("#\[dt_divider.*\](.*)\[dt_#Us", $content, $matches3);
$picsize = $matches3[1][0];
print $picsize;
,然後試圖讓價格使用:
preg_match_all("#\[dt_divider.*\](.*)\[/vc_#Us", $content, $matches4);
$price = $matches4[1][0];
print $picsize;
上面的代碼只是陣列出來:
Array ([0] => Array ([0] => [dt_divider style="thin"/] size 18" x 18" [dt_divider style="thin"/] £70[/vc_) [1] => Array ([0] => size 18" x 18" [dt_divider style="thin"/] £70))
我如何得到它忽略第一個[dt_divider style="thin"/]
所以它只是拿起第二?
希望是有道理:-)
這工作出色!非常感激! – user1857612
@ user1857612很高興爲您提供幫助 – OGHaza