开发者

Split String at the first five <br />'s with php

<?php

$text = <<<EOT

<br /> 1  <br /开发者_如何学运维> 2 <br />  3  <br /> 4 <br /> 5  <br /> 6 
<br /> 7  <br /> 8 <br />  9  <br /> 10 <br /> 11  <br /> 12 
<br /> 13  <br /> 14 <br />  15  <br /> 16 <br /> 17  <br /> 18 

EOT;
?>

I want split $txt and result

$txt="
<br /> 1  <br /> 2 <br />  3  <br /> 4 <br /> 5 ";

I want split position 5 of <br />

1,2,3,4 is random string Please help me


Try this:

$arr = array_splice(explode('<br />',$text),0,6);  
$result = implode('<br />',$arr);

Working link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜