notnak Posted March 31, 2007 Share Posted March 31, 2007 Hello, I am trying to split the $content into lines, but avoid breaking the html tags. (Inside content is an html page) while (strlen($content)>0) { $thous = substr($content,0,1000);//get current digit for ($z=1000; $z > 0 ; $z--) { $onec = substr($thous,$z,1); if ( $onec = '>' ) { $current++; $line[$current]=substr($content,0,$z);//get current digit $content=substr($content,$z,strlen($content));//reduce number string to remove last stored digit } } } What's wrong? Thanks a lot in advance for any help. Link to comment https://forums.phpfreaks.com/topic/45085-html-newbie-question-thanks/ Share on other sites More sharing options...
poirot Posted April 1, 2007 Share Posted April 1, 2007 To do what you are trying to you would need Regular Expressions or similar methods, so I recommend you just to wrap it using HTML/CSS. Link to comment https://forums.phpfreaks.com/topic/45085-html-newbie-question-thanks/#findComment-219127 Share on other sites More sharing options...
neel_basu Posted April 1, 2007 Share Posted April 1, 2007 Can you show the $content ?? Are you trying to do Word Wrap ?? Link to comment https://forums.phpfreaks.com/topic/45085-html-newbie-question-thanks/#findComment-219181 Share on other sites More sharing options...
swatisonee Posted April 1, 2007 Share Posted April 1, 2007 Try $content = $myrow["Content"]; $content1=stripslashes($content); //strip / $content2 = nl2br ($content1); //convert CR to BR Link to comment https://forums.phpfreaks.com/topic/45085-html-newbie-question-thanks/#findComment-219185 Share on other sites More sharing options...
notnak Posted April 2, 2007 Author Share Posted April 2, 2007 Thanks for your kind replies. I just want to break an ebook (simple html) into chucks of 1000 chars in order to load them into the Virtual Pagination class. http://www.dynamicdrive.com/dynamicindex17/virtualpagination.htm So, I have to maintain the html, but can't break the html when I am inside an html tag. Link to comment https://forums.phpfreaks.com/topic/45085-html-newbie-question-thanks/#findComment-219482 Share on other sites More sharing options...
notnak Posted April 2, 2007 Author Share Posted April 2, 2007 Any help would be great.. thanks. Link to comment https://forums.phpfreaks.com/topic/45085-html-newbie-question-thanks/#findComment-219974 Share on other sites More sharing options...
neel_basu Posted April 2, 2007 Share Posted April 2, 2007 $content = file_get_contents("ebook.htm"); $wraped = wordwrap($content, 1000, "<br />\n"); echo $wraped Link to comment https://forums.phpfreaks.com/topic/45085-html-newbie-question-thanks/#findComment-219981 Share on other sites More sharing options...
notnak Posted April 2, 2007 Author Share Posted April 2, 2007 $content = file_get_contents("ebook.htm"); $wraped = wordwrap($content, 1000, "<br />\n"); echo $wraped Thanks for the tip neel_basu, but that would not avoid breaking the html tags, or does the wordwarp interprets and respects html code? Link to comment https://forums.phpfreaks.com/topic/45085-html-newbie-question-thanks/#findComment-220179 Share on other sites More sharing options...
notnak Posted April 4, 2007 Author Share Posted April 4, 2007 Any other tips? Thanks. Link to comment https://forums.phpfreaks.com/topic/45085-html-newbie-question-thanks/#findComment-221312 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.