$attributes['st_title']
的值为<a href="/physical-design-engineers">Physical Design Engineers</a>
我想删除<a href="/physical-design-engineers">
和</a>
。最终预期输出为:$attributes['st_title'] = Physical Design Engineers
我正在尝试如下:
$pattern[0] = "/<a.[^>]+>/";
$pattern[1] = '/</a>/';
$replacement[1] = '';
$replacement[0] = '';
$attributes['st_title'] = preg_replace( $pattern, $replacement, $attributes['st_title'] );
但是它将$attributes['st_title']
设置为空。有什么想法吗?
答案 0 :(得分:4)
答案 1 :(得分:2)
使用php strip_tags()
或
preg_replace("/<.*?>/", "", $attributes['st_title']);