Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 1.89 KB

readme.md

File metadata and controls

47 lines (35 loc) · 1.89 KB

String Functions

Build Status Code Quality Code Coverage Version License

Example

use TypedPHP\Functions\StringFunctions;

StringFunctions\endsWith("a long string", "string"); // true
StringFunctions\replace("a long string", "long", "enormous"); // "a enormous string"

Functions:

  • startsWith(string $haystack, string $needle) → bool
  • endsWith(string $haystack, string $needle) → bool
  • indexOf(string $haystack, string $needle, int $offset = 0) → int
  • length(string $string) → int
  • matches(string $haystack, string $needle) → bool
  • replace(string $haystack, string|array $needle, string|array $replacement) → string
  • slice(string $string, int $offset = 0, int $limit = 0) → string
  • split(string $haystack, string|null $needle = null, int $limit = 0) → array
  • trim(string $haystack, string $needle) → string
  • trimLeft(string $haystack, string $needle) → string
  • trimRight(string $haystack, string $needle) → string

Caveats:

  • Every $needle can be a normal string or a regular expression string.

Installation

❯ composer require "typedphp/string-functions:*"

Testing

❯ composer create-project "typedphp/string-functions:*" .
❯ vendor/bin/phpunit