mulertech/char-manipulation

This class manipulates characters

v1.0.4 2024-12-30 21:34 UTC

This package is auto-updated.

Last update: 2025-02-28 21:32:51 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub PHPStan Action Status Total Downloads Test Coverage

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 &quot;trim&quot;', 'with', 'array', 'and', 'null', null]

specialCharsDecode (decode chars into string or array by reference, no return) :
$test = '&#039;test single quote';
CharManipulation::specialCharsDecode($test);

// echo $test;
// "'test single quote";
$test = [
            'test1' => '&#039;test single quote',
            'test2' => 'test quote&quot;',
            'test3' => 'with null',
            'test4' => null,
            'test5' => [
                'test5a' => "&#039;test single quote",
                'test5b' => 'test quote&quot;',
                '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
        ]
   ];