Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我想忽略html标记中的strong,它在php中包含空格_Php - Fatal编程技术网

我想忽略html标记中的strong,它在php中包含空格

我想忽略html标记中的strong,它在php中包含空格,php,Php,例如,如果我有以下格式的数组 <div><strong>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</strong></div> <div><strong>Ravjaja</strong></div> <div><strong>&nbsp;&nbsp; &nbsp; &nbsp;

例如,如果我有以下格式的数组

<div><strong>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</strong></div>

<div><strong>Ravjaja</strong></div>

<div><strong>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</strong></div>

<div><strong>yuaiiaiia</strong></div>

<div></div>

Ravjaja

yuaiiaiia
我想从空格中忽略,这意味着在删除

<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div>

<div><strong>Ravjaja</strong></div>

<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>

<div><strong>yuaiiaiia</strong></div>

<div></div>

<div></div>

Ravjaja
yuaiiaiia
我有没有想过用php中的数组函数进行拆分和替换 我试过这样做

$keywords=preg_split(“
”,$lval); 打印(关键字); 我想提取每个标签并删除strong,但我无法用那种方式来做

$elements=array(
$elements = array(
    '<div><strong>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</strong></div>',
    '<div><strong>Ravjaja</strong></div>',
    '<div><strong>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</strong></div>',
    '<div><strong>yuaiiaiia</strong></div>',
    '<div></div>'
);

foreach ($elements as $key => $element) {
    if (strpos('&nbsp', $element) !== FALSE) {
        $elements[$key] = str_replace('<strong>', '', $element);
        $elements[$key] = str_replace('</strong>', '', $element);
    }
}
”, “Ravjaja”, “”, “yuaiiaiia”, '' ); foreach($key=>$element形式的元素){ if(strpos('nbsp',$element)!==FALSE){ $elements[$key]=str_replace(“”,“$element”); $elements[$key]=str_replace(“”,“$element”); } }
唯一可能的方法应该是这样

   $my_array=str_replace("<div><strong>&nbsp;","<div>",$my_array);
   $my_array=str_replace("&nbsp;</strong>","",$my_array);
$my\u array=str\u replace(“”,“,$my\u array”);
$my\u array=str\u replace(“”,“”,$my\u array);

您尝试过什么?请阅读。很抱歉,我是stackoverflow新手,感谢您为解决方案提出建议,但我仍然需要对数组进行优化,如果数组(“”、“Ravjaja”、“”、“YuaiIIA”、”)我给的已经是数组中的一个值了,有没有一种方法可以拆分它?没有得到,你能不能详细说明Explode(“”,$htmlString)将吐出你的字符串ibto数组,你可以使用我的解决方案,然后使用你告诉我的方法,但我认为它不起作用,因为我发现控件没有进入if循环,如果我不正确,你能检查一下吗