[code=php]$limit = 400;

if (strlen($summary) > $limit)
      $summary = substr($summary, 0, strrpos(substr($summary, 0, $limit), ' ')) . '...';
      echo $summary;

I am using bbcode in my script
but bbcode could not show if I limited my body string.
because the end tags of bbcode will cut off.[/code]

    vividona;10944495 wrote:
    [code=php]$limit = 400;
    
    if (strlen($summary) > $limit)
          $summary = substr($summary, 0, strrpos(substr($summary, 0, $limit), ' ')) . '...';
          echo $summary;

    I am using bbcode in my script
    but bbcode could not show if I limited my body string.
    because the end tags of bbcode will cut off.[/code]

    if its always going to be [/code] at the end then:

    $limit = 400;
    $summary=substr($summary,0,-6);
    if (strlen($summary) > $limit)
          $summary = substr($summary, 0, strrpos(substr($summary, 0, $limit), ' ')) . '...

    ';
    echo $summary;[/code]

      the boards bbcode messed up the bbcode, but i assume you get the idea.

        dagon;10944496 wrote:

        if its always going to be [/code] at the end then:

        $limit = 400;
        $summary=substr($summary,0,-6);
        if (strlen($summary) > $limit)
              $summary = substr($summary, 0, strrpos(substr($summary, 0, $limit), ' ')) . '...

        ';
        echo $summary;[/code]

        Hi,
        There are also
        colors, font size , email links, website links and images links

          5 days later
          Write a Reply...