Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.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
在php中为每个html元素创建新的数组值_Php_Arrays_String - Fatal编程技术网

在php中为每个html元素创建新的数组值

在php中为每个html元素创建新的数组值,php,arrays,string,Php,Arrays,String,我正试图将此字符串: > President Obama pointed blabla<br /> <br /> The only way I get this > stuff <br /> <br /> I'm consulting with the Pentagon, with <br /> <br > /> 我尝试使用explode(“,$string),但它不起作用。有什么想法吗?尝试在explo

我正试图将此字符串:

> President Obama pointed blabla<br /> <br /> The only way I get this
> stuff <br /> <br /> I'm consulting with the Pentagon, with <br /> <br
> />

我尝试使用
explode(“

,$string)
,但它不起作用。有什么想法吗?

尝试在
explode
函数中的

标记之间添加一个空格。

看起来您只需要删除每行的前两个字符(“>”),连接所有行,然后进行分解(注意缺少的空格,正如其他人指出的那样)。

在您的情况下
explode(“

,$string);
可以


更一般地说,如果有一些行由



,“

,$string”分隔,有些行由


分隔,有些行由



分隔,则可以在前一行前面添加:
,,除非是打字错误,否则在explode()中缺少空格在每个
之间。或者,您可以执行以下操作:

array (
[0] => President Obama pointed blabla
[1] => The only way I get this stuff 
[2] => I'm consulting with the Pentagon, with 
);
$br2arr = array_filter(preg_split("/([\s\b]*<br \/>[\s\b]*)|([\s\b]*<br>[\s\b]*)/", $str));
$br2arr=array_filter(preg_split(“/([\s\b]*[\s\b]*))|([\s\b]*
[\s\b]*)/”,$str);
在任何情况下,它都可以执行您想要的操作/格式

分解(“

,$string)
请注意2个

之间的空格。