protected function segmentLine($text)
    {
        list($lines, $temp, $width) = [[], '', 0];

        foreach (preg_split('//u', $text, -1, PREG_SPLIT_NO_EMPTY) as $word) {
            if ($width + mb_strwidth($word) > 48) {
                $lines[] = $temp;
                $temp = '';
                $width = 0;
            }

            $temp .= $word;
            $width += mb_strwidth($word);
        }

        $lines[] = $temp;

        return implode(PHP_EOL, $lines);
    }
protected function segmentLine($text)
    {
        list($lines, $temp, $width) = [[], '', 0];

        foreach (preg_split('//u', $text, -1, PREG_SPLIT_NO_EMPTY) as $word) {
            if ($width + mb_strwidth($word) > 48) {
                $lines[] = $temp;
                $temp = '';
                $width = 0;
            }

            $temp .= $word;
            $width += mb_strwidth($word);
        }

        $lines[] = $temp;

        return implode(PHP_EOL, $lines);
    }
protected function segmentLine ( $ text ) { list ( $ lines , $ temp , $ width ) = [ [ ] , '' , 0 ] ; foreach ( preg_split ( '//u' , $ text , - 1 , PREG_SPLIT_NO_EMPTY ) as $ word ) { if ( $ width + mb_strwidth ( $ word ) > 48 ) { $ lines [ ] = $ temp ; $ temp = '' ; $ width = 0 ; } $ temp .= $ word ; $ width += mb_strwidth ( $ word ) ; } $ lines [ ] = $ temp ; return implode ( PHP_EOL , $ lines ) ; }
Segment text to multiple lines if needed.

@param string $text

@return string
Segment text to multiple lines if needed .