Jump to content

[SOLVED] Split after paragraph


swamp

Recommended Posts

Hi there, I've got this code that spilts content into blocks of 900 characters:

 

<? //split content into divs
$i=0;
for($t=0; $t<strlen($post);$t++){
if($t%902==0) $i++;
$out[$i].=$post{$t};
}
?>

<?
foreach($out as $k=>$v)
{
//echo '<div id="content_'.$k.'">'.$v

?>

<div id="content_<? echo $k ?>">
<p>
<? echo nl2br($v) ?>
    </p>
    <p>

<? 
if ( $k == 1 ) {
echo " ";
} else {
 //echo $k -1; 
 ?>  <span class="arrow-back"><a href="#" onClick="setVisible('content_<? echo $k -1; ?>');">previous page</a></span>
<? } ?>


  <? 
if ( $k == count($out) ) {
echo " ";
} else {
 //echo $k -1; 
 ?>  <span class="arrow"><a href="#" onClick="setVisible('content_<? echo $k +1; ?>');">next page</a></span>
<? } ?>

</p>
</div>

<? 

}

?>

 

It all works fine, but how can I make it so it will only put text in a new div after the end of a paragraph (the paragraphs are seperated with <br /> ?

 

Thanks for any advice on this.

Link to comment
https://forums.phpfreaks.com/topic/121681-solved-split-after-paragraph/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.