rafaeldsb/php-string-tags

helpers who assist in string tags.

v0.1.1 2020-02-09 05:04 UTC

This package is auto-updated.

Last update: 2024-11-06 18:10:38 UTC


README

Total Downloads Latest Stable Version Codacy grade Codacy coverage CircleCI

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