Contents

WebsiteParser::truncateText( $text,  $length = 50,  $replace_by = '...' )

Truncate text in to preferred length

Description

Source

File: bp-activity/vendors/website-parser/website_parser.php

    public function truncateText($text, $length = 50, $replace_by = '...')
    {
        $text_parts = explode('_____', wordwrap($text, $length, "_____", false));
        $new_text = array_shift($text_parts);

        if (strlen($text) > strlen($new_text)) {
            return $new_text . $replace_by;
        }

        return $text;
    }

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.