这是我的代码:
$desc = "this <br>is a test";
$maxLen = 7;
$structured_desc = "<span>" . mb_substr($desc,$maxLen) . "</span>" . mb_substr($desc,$maxLen);
echo $structured_desc;
这是上面代码的结果:
// output: <span>this <b</span>r>is a test
现在我要避免发生这种情况。我的意思是,</span>
不能添加在<br>
标记的中间。
注意::我保证该字符串是仅包含<br>
标签的字符串。
因此,如果</span>
标签之间有任何意外(最好在此之前),则应在<br>
标签之前或之后添加{1>}标签。
任何想法我该怎么做?
这是预期的结果:
// expected output: <span>this </span><br>is a test