我想在所有< span>之间的数组中获取文本. < /跨度>标签从
HTML,我尝试过这个代码,但它只返回一个事件:
- preg_match('/<span>(.+?)<\/span>/is',$row['tbl_highlighted_icon_content'],$matches);
- echo $matches[1];
我的HTML:
- <span>The wish to</span> be unfairly treated is a compromise attempt that would COMBINE attack <span>and innocen</span>ce. Who can combine the wholly incompatible,and make a unity of what can NEVER j<span>oin? Walk </span>you the gentle way,
您需要切换到
preg_match_all功能
码
- $row['tbl_highlighted_icon_content'] = '<span>The wish to</span> be unfairly treated is a compromise attempt that would COMBINE attack <span>and innocen</span>ce. Who can combine the wholly incompatible,and make a unity of what can NEVER j<span>oin? Walk </span>you the gentle way,';
- preg_match_all('/<span>.*?<\/span>/is',$matches);
- var_dump($matches);
正如你可以看到的,数组是正确填充的,所以你可以回应所有的匹配