的img我使用preg_replace
從$content
某些<img>
刪除:
$content=preg_replace('/(?!<img.+?id="img_menu".*?\/>)(?!<img.+?id="featured_img".*?\/>)<img.+?\/>/','',$content);
當我現在顯示使用WordPress的the_content功能的內容,我確實刪除<img>
小號從$content
:
我想事先獲取此圖像將它們放在模板中的其他地方。我使用與preg_match_all
相同的正則表達式模式:
preg_match_all('/(?!<img.+?id="img_menu".*?\/>)(?!<img.+?id="featured_img".*?\/>)<img.+?\/>/', $content, $matches);
但我不能讓我的IMGS?
preg_match_all('/(?!<img.+?id="img_menu".*?\/>)(?!<img.+?id="featured_img".*?\/>)<img.+?\/>/', $content, $matches);
print_r($matches);
Array ([0] => Array ())
的感謝!那看起來很棒!我已經解決了我的問題,但請記住下次 – Matoeil