PHP code example of rafaeldsb / php-string-tags

1. Go to this page and download the library: Download rafaeldsb/php-string-tags library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rafaeldsb / php-string-tags example snippets




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




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