public function parseText(String $text)
    {
        // Space after . and next word begin with uppercase
        $pieces = explode('.', $text);
        $new_pieces = [];
        foreach ($pieces as $piece) {
            array_push($new_pieces, ucfirst($piece));
        }
        $text = implode('. ', $new_pieces);

        // Space after ? and next word begin with uppercase
        $pieces = explode('?', $text);
        $new_pieces = [];
        foreach ($pieces as $piece) {
            array_push($new_pieces, ucfirst($piece));
        }
        $text = implode('? ', $new_pieces);

        // Space after ,
        $pieces = explode(',', $text);
        $text = implode(', ', $pieces);

        return $text;
    }
public function parseText(String $text)
    {
        // Space after . and next word begin with uppercase
        $pieces = explode('.', $text);
        $new_pieces = [];
        foreach ($pieces as $piece) {
            array_push($new_pieces, ucfirst($piece));
        }
        $text = implode('. ', $new_pieces);

        // Space after ? and next word begin with uppercase
        $pieces = explode('?', $text);
        $new_pieces = [];
        foreach ($pieces as $piece) {
            array_push($new_pieces, ucfirst($piece));
        }
        $text = implode('? ', $new_pieces);

        // Space after ,
        $pieces = explode(',', $text);
        $text = implode(', ', $pieces);

        return $text;
    }
public function parseText ( String $ text ) { // Space after . and next word begin with uppercase $ pieces = explode ( '.' , $ text ) ; $ new_pieces = [ ] ; foreach ( $ pieces as $ piece ) { array_push ( $ new_pieces , ucfirst ( $ piece ) ) ; } $ text = implode ( '. ' , $ new_pieces ) ; // Space after ? and next word begin with uppercase $ pieces = explode ( '?' , $ text ) ; $ new_pieces = [ ] ; foreach ( $ pieces as $ piece ) { array_push ( $ new_pieces , ucfirst ( $ piece ) ) ; } $ text = implode ( '? ' , $ new_pieces ) ; // Space after , $ pieces = explode ( ',' , $ text ) ; $ text = implode ( ', ' , $ pieces ) ; return $ text ; }
Parse long texts. Adds spaces and uppercases where necessary.
@param String $text
@return String
Parse long texts . Adds spaces and uppercases where necessary .