This librairy provides utilities function to ease string manipulation
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 ...
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);
phpunit --bootstrap vendor/autoload.php tests
Hugo Maugey visit my website ;)