Php-Str_替换不识别空白
我有一个非常简单的问题。我需要把整个Php-Str_替换不识别空白,php,preg-replace,str-replace,Php,Preg Replace,Str Replace,我有一个非常简单的问题。我需要把整个 <td colspan="3" rowspan="1"> </td> 仅当标记为空时才从html中获取标记(虽然它不是完全空的,但有一些空格)。尝试使用: $html = str_replace("<td colspan=\"3\" rowspan=\"1\"> </td>","",$html); $html = str_replace("<td colspan=\"3\" rows
<td colspan="3" rowspan="1"> </td>
仅当标记为空时才从html中获取标记(虽然它不是完全空的,但有一些空格)。尝试使用:
$html = str_replace("<td colspan=\"3\" rowspan=\"1\"> </td>","",$html);
$html = str_replace("<td colspan=\"3\" rowspan=\"1\"> </td>","",$html);
$html=str\u replace(“,”,$html);
$html=str_replace(“,”,$html);
没有成功
preg_replace("/<td[^>]*>[\s| ]*<\/td>/", '', $html);
preg_replace(“/]*>[\s |]*/”,“'$html);
也没用
这应该是一个相当简单的解决方案,有什么建议吗?也许是这个?它还将匹配多个空格(如果存在)
<?php
$result = preg_replace('#<td[^>]*>([\s]| )*<\/td>#i', '', $html);
var_dump($result);
试试这个]*>([\s]|)?
应该可以用。你得到了什么?它只是不能取代html。先前建议的preg也不能正常工作。