Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: [break] inside paragraph breaks validation  (Read 9629 times)

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[break] inside paragraph breaks validation
« Reply #15 on: April 29, 2007, 09:26:48 AM »

maybe scrap both the above, and use this ;)
(nutted out with mika)
grey is original code in file_include() function
brown is my comments, and can safely be stripped at your leisure
blue is new code
Quote
function file_include($text, $shorten) {
   $fulltext = substr($text, 0, $shorten);

if ($shorten < 9999000 && preg_match('<p>',$fulltext)){
// count all start and end tags, provided count of <p> is more, add </p>
   if(substr_count ($fulltext, '<p>') > substr_count ($fulltext, '</p>')){
   $fulltext .='</p>';}}

   $inc = strpos($fulltext, '[/include]');
   if ($inc > 0) {
      $text = str_replace('[include]', '|&|', $fulltext);
The assumption I am making is that user is applying correct formatting throughout article, but wants to break a paragraph into a small 'snippet' for display in short text.

This will not rectify shoddy html formatting :D
« Last Edit: January 27, 2008, 11:08:13 PM by philmoz »
Logged
Of all the things I have lost, it is my mind that I miss the most.

codetwist

  • Hero Member
  • *****
  • Karma: 50
  • Posts: 940
[break] inside paragraph breaks validation
« Reply #16 on: April 29, 2007, 09:52:48 AM »

Compact one, indeed ;)
Logged
Pages: 1 [2]