alexeyyashin / estring
v1.3.0
2022-02-13 17:06 UTC
This package is auto-updated.
Last update: 2024-06-05 12:25:04 UTC
README
estring 是为了在 PHP 中进行更简单的字符串操作而制作的,就像 JS 一样。
安装
目前唯一的选择是使用 Composer
composer require alexeyyashin/estring
示例
$first = ' Some string to operate'; // PHP functions $second = $first; if (strpos(strtolower(trim($second)), 'some') === 0) { echo str_replace('Some', 'Awesome', trim($second)) . "\n"; echo "found\n"; } elseif (substr(strtolower(trim($second)), - strlen('operate')) === 'operate') { echo str_replace('operate', 'control', trim($second)) . "\n"; echo "found but ending\n"; } // Same with estring $third = estring($first); if ($third->trim()->startsWith('some', true)) { echo $third->trim()->replace(['Some' => 'Awesome']) . "\n"; echo "found\n"; } elseif ($third->trim()->endsWith('operate')) { echo $third->trim()->replace(['operate' => 'control']) . "\n"; echo "found but ending\n"; }
更多详情请查阅文档
(尚未完成) Usage.md