Some useful functions for working with strings
Just run the following command: composer require ludovicm67/strings
to add it to your PHP project!
If you installed using composer, you can now create a file with the following code:
<?php
// import here the composer autoloader
require('./vendor/autoload.php');
// use the namespace for this library
use ludovicm67\Strings\Strings;
You can clean strings using the static method: Strings::clean("My string")
.
Example:
echo Strings::clean("test& ""~ "@éa/-âå€ÊÂøʱæ€ûýþ<b>bold</b>");
// will display: test& ""~ "@éa/-âå€ÊÂøʱæ€ûýþ<b>bold</b>
Using Strings::fromCamelCase("myString")
(will return: my-string
).
Example:
echo Strings::fromCamelCase('testFromCamelCase');
// will display: test-from-camel-case
Using Strings::toCamelCase("my-string")
(will return: myString
).
Example:
echo Strings::toCamelCase('test-to-camel-case');
// will display: testToCamelCase
Just fork, commit and open a pull-request. Or just open an issue here: https://github.com/ludovicm67/php-strings/issues .