1. Go to this page and download the library: Download dana/interpolator 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/ */
dana / interpolator example snippets
$interpolator = new Interpolator();
// Basic usage: Both of these print 'Hello, dana!'
echo $interpolator->render('Hello, %{0}!', ['dana']), "\n";
echo $interpolator->render('Hello, %{name}!', ['name' => 'dana']), "\n";
// Filter usage: This prints 'Hello, DANA!' (u = upper-case)
echo $interpolator->render('Hello, %{0|u}!', ['dana']), "\n";
// Filter usage: This prints 'Hello, "DANA"!' (u = upper-case, j = JSON-encode)
echo $interpolator->render('Hello, %{0|uj}!', ['dana']), "\n";
// Filter usage: This prints 'Hello, 38095!' (c = CRC32, d = extract digits)
echo $interpolator->render('Hello, %{0|cd}!', ['dana']), "\n";
$interpolator = new Interpolator();
// Replace all default filters by our own
$interpolator->setFilters(['a' => 'ucfirst']);
// This prints 'Foo'
echo $interpolator->render('%{0|a}', ['foo']), "\n";
$interpolator = new Interpolator();
// Apply htmlspecialchars() as an auto filter
$interpolator->setAutoFilters('h');
// This prints 'FOO&BAR'
echo $interpolator->render('%{0|u}', ['foo&bar']), "\n";
// This prints 'FOO&BAR' (auto filters suppressed)
echo $interpolator->render('%{0|u-}', ['foo&bar']), "\n";