用换行符包裹的<br>标签分割字符串

问题描述 投票:0回答:1

我们有行:

1 test1
<br> 
2 test2
<br> 
3 test3
<br> 
4 test4

对于数组中的爆炸,我们接下来测试:

$ArrText = explode("\n",$text);
$ArrText = explode("<br>",$text);

但是没有成功。

请告诉我如何将字符串拆分为数组元素?

php arrays split
1个回答
5
投票
$ArrText = explode("\n<br>\n",$text);

有两件事:

  1. 您必须用一个新行进行分割,然后是一个
    <br>
    ,然后是一个新行
  2. 转义字符仅适用于双引号,不适用于单引号
© www.soinside.com 2019 - 2024. All rights reserved.