Skip to content

Rafaeldsb/php-string-tags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-string-tags

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

About

Helpers who assist in string tags

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages