alexeyyashin / estring
EString
Installs: 199
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
pkg:composer/alexeyyashin/estring
This package is auto-updated.
Last update: 2024-06-05 12:25:04 UTC
README
estring was made for simpler strings operations in PHP just like JS does
Installation
Right now the only option is using Composer:
composer require alexeyyashin/estring
Example
$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"; }
See more info in documentation
(not finished yet) Usage.md