Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

Latest commit

 

History

History
40 lines (23 loc) · 1.78 KB

README.md

File metadata and controls

40 lines (23 loc) · 1.78 KB

php-string-plus

More string helpers for PHP (and Laravel).

Build Status Latest Stable Version Latest Unstable Version License Total Downloads

Usage

Require the package in your composer.json file:

"spiegeleye/php-string-plus": "1.3.*"

In your PHP file add use StrPlus\StrPlus; for convenience.

Helpers

StrPlus::replace_control_chars($replace, $string)

Replaces non-printable control characters in $string with $replace.

StrPlus::single_line($string)

Converts a multi-line text to a text without line breaks or other non-printable characters. Multiple successive spaces are reduced to one sinle space.

StrPlus::function html_to_single_line_text($string)

Converts a HTML formatted block to a plain text one-line string without non-printable characters.

StrPlus::multi_line_text_to_html($string)

Converts a multi-line plain text string to a multi-line HTML string where line breaks become <br> tags.

StrPlus::limit($string, $limit, $end = null, $preserve_words = true)

Limit string to a number of characters and preserve words where possible (optional; default is true). If $end is not set or null the default character will be used.