开发者

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

开发者 https://www.devze.com 2023-01-19 01:49 出处:网络
<?php $text = <<<EOT <br /> 1<br /开发者_如何学运维> 2 <br />3<br /> 4 <br /> 5<br /> 6
<?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

精彩评论

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