hugsbrugs/php-string

There is no license information available for the latest version (1.2) of this package.

PHP String Utilities

1.2 2022-04-04 10:56 UTC

This package is auto-updated.

Last update: 2024-04-04 15:18:40 UTC


README

This librairy provides utilities function to ease string manipulation

Build Status Coverage Status

Install

Install package with composer

composer require hugsbrugs/php-string

In your PHP code, load library

require_once __DIR__ . '/../vendor/autoload.php';
use Hug\HString\HString as HString;

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

Usage

Replace the last occurrence of a string

$string = HString::str_replace_last($search, $replace, $subject);

Checks whether a string starts with given chars

$bool = HString::starts_with($haystack, $needle);

Checks whether a string ends with given chars

$bool = HString::ends_with($haystack, $needle);

Checks whether a string contains utf8mb4 chars (Chars coded on 4 bytes)

$bool = HString::is_utf8mb4($search);

Unit Tests

phpunit --bootstrap vendor/autoload.php tests

Author

Hugo Maugey visit my website ;)