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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.