我有一个包含以下html代码的变量
Bloom's: Knowledge<br> Difficulty: Medium<br> Learning Objective: 01-03 <br> Topic: Economic<br>
我想使用preg_replace删除每个'Bloom's:...','难度:....','学习目标:......','主题:......'
我试图匹配这些条款,但它不起作用。
/Bloom's:.*<br>/ or /Difficulty:.*<br>
你能告诉我正确的方法吗?非常感谢!
答案 0 :(得分:0)
不确定你想要什么但是:
$whole_question = "Bloom's: Knowledge<br> Difficulty: Medium<br> Learning Objective: 01-03 <br> Topic: Economic<br>";
$removeKeys = array(
'Bloom:',
'Difficulty:',
'Learning Objective:',
'Topic:',
);
foreach ($removeKeys as $removeKey){
$removeKey = '/'.$removeKey.'.*<br>/';
$whole_question = preg_replace($removeKey,'<br>',$whole_question);
}
echo $whole_question;//Bloom's: Knowledge<br> <br>