webikevn/wstring

PHP String Utilities

1.0.2 2020-08-21 06:04 UTC

This package is auto-updated.

Last update: 2024-11-21 15:40:19 UTC


README

This librairy provides utilities function to ease string manipulation

Install

Install package with composer

composer require webikevn/wstring

In your PHP code, load library

require_once __DIR__ . '/../vendor/autoload.php';
use Webike\WString\WString as WString;

Note: I couldn't use String as namespace because it's a PHP reserved word so it's why namespace is WString ...

Usage

Replace the last occurrence of a string

$string = WString::strReplaceLast($search, $replace, $subject);

Checks whether a string starts with given chars

$bool = WString::startsWith($haystack, $needle);

Checks whether a string ends with given chars

$bool = WString::endsWith($haystack, $needle);

Unit Tests

phpunit --bootstrap vendor/autoload.php tests

Author

Nguyen Giang visit my website ;)