rafaeldsb / php-string-tags
helpers who assist in string tags.
v0.1.1
2020-02-09 05:04 UTC
Requires
- php: >=7.3
Requires (Dev)
- codacy/coverage: dev-master
- phpunit/php-code-coverage: ^8.0
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-11-06 18:10:38 UTC
README
This package is a helper for tags in strings
Installation
composer require rafaeldsb/php-string-tags
Basic Usage
<?php use RafaelDsb\Helpers\Tag; $string = 'A string with a {{key}} and a {{tag}}'; $keys = Tag::getTags($string); // It returns ['key', 'tag'] $newString = Tag::replaceTags($string, ['key' => 'little key', 'tag' => 'door']); echo $newString; // A string with a little key and a door
Advanced Usage
You can use it with other characters to process the tags
<?php use RafaelDsb\Helpers\Tag; $string = 'A string with a <key> and a <tag>'; $keys = Tag::getTags($string, '<', '>'); // It returns ['key', 'tag'] $newString = Tag::replaceTags($string, ['key' => 'little key', 'tag' => 'door'], '<', '>'); echo $newString; // A string with a little key and a door