dmeroff/string

PHP 5.3 String manipulation library

Maintainers

👁 dmeroff

Package info

github.com/dmeroff/string

pkg:composer/dmeroff/string

Statistics

Installs: 39

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

v1.0 2013-07-15 14:00 UTC

Requires

None

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT db373b8aef83fa7e0d9c904fc1d5c221e9dda89b

string

This package is not auto-updated.

Last update: 2026-06-15 22:33:18 UTC


README

String class

String is a class that turns string into PHP objects. It implements a fluent interface, improving how we manipulate strings, and extends functionality by providing common functions.

Imagine that you need to replace "hello" to "goodbye" and make first letter uppercase. In classic PHP it would like something like this:

$string = 'hello, world';
$string = str_replace('hello', 'goodbye', $string);
$string = ucfirst($string);
echo $string; // Goodbye, world

Using the String class it gets simpler:

$string = 'hello, world';
$string = new String\String($string);
echo $string->replace('hello', 'goodbye')->sentencecase(); // Goodbye, world

OR

$string = 'hello, world';
echo String\String::make($string)->replace('hello', 'goodbye')->sentencecase(); // Goodbye, world

LetterPairSimilarity class

This class can be used to compare string using "Strike a match" algorithm.

$similarity = String\LetterPairSimilarity::compare('Healed', 'Healthy');
echo round($similarity, 2); // 0.55

Requirements

  • PHP 5.3 and higher
  • mbstring extension