mulertech / char-manipulation
This class manipulates characters
v1.0.4
2024-12-30 21:34 UTC
Requires
- php: ^8.2
Requires (Dev)
- mulertech/docker-tests: ^1.0
- phpunit/phpunit: ^10|^11
- roave/security-advisories: dev-latest
README
This class manipulates characters
Installation
Two methods to install Application package with composer :
Add to your "composer.json" file into require section :
"mulertech/char-manipulation": "^1.0"
and run the command :
php composer.phar update
Run the command :
php composer.phar require mulertech/char-manipulation "^1.0"
Usage
specialCharsTrim, trim and convert special characters to HTML entities :
CharManipulation::specialCharsTrim(' Test trim ');
// 'Test trim'
CharManipulation::specialCharsTrim('<script\>Test without html balise</script>');
// 'Test without html balise'
CharManipulation::specialCharsTrim([' Test "trim"', '<script\>with</script>', ' array ', ' and', 'null ', null]);
// ['Test "trim"', 'with', 'array', 'and', 'null', null]
specialCharsDecode (decode chars into string or array by reference, no return) :
$test = ''test single quote';
CharManipulation::specialCharsDecode($test);
// echo $test;
// "'test single quote";
$test = [
'test1' => ''test single quote',
'test2' => 'test quote"',
'test3' => 'with null',
'test4' => null,
'test5' => [
'test5a' => "'test single quote",
'test5b' => 'test quote"',
'test5c' => 'with null',
'test5d' => null
]
];
CharManipulation::specialCharsDecode($test);
// echo $test;
// [
'test1' => "'test single quote",
'test2' => 'test quote"',
'test3' => 'with null',
'test4' => null,
'test5' => [
'test5a' => "'test single quote",
'test5b' => 'test quote"',
'test5c' => 'with null',
'test5d' => null
]
];