hugsbrugs / php-string
PHP String Utilities
Installs: 122 627
Dependents: 5
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
This package is auto-updated.
Last update: 2024-11-04 16:28:19 UTC
README
This librairy provides utilities function to ease string manipulation
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 ;)