PHP code example of hollyit / token-replace

1. Go to this page and download the library: Download hollyit/token-replace 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/ */

    

hollyit / token-replace example snippets

  
$input="Today is { date:m }}/{{ date:d }}/{{ date:y }}.";  
  
echo \HollyIT\TokenReplace\TokenReplacer::from($input)  
    ->with('date',  \HollyIT\TokenReplace\Transformers\DateTransformer::class)  
      
// Results in: Today is 11/11/21.      
  

\HollyIT\TokenReplace\TokenReplacer::$defaultTransformers = [  
  'date' => \HollyIT\TokenReplace\Transformers\DateTransformer::class  
];

$replacer->onReplace(function(string $result, string $token, string $options){  
  return strtoupper($result);  
});