PHP code example of jlibs / php-string-max

1. Go to this page and download the library: Download jlibs/php-string-max 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/ */

    

jlibs / php-string-max example snippets



use JLibs\StringMax;

echo StringMax::format(
    'Hi {{name}}, keep {{tip}}!',
    [
        'name' => 'developer',
        'tip' => 'building'
   ]
);
// prints: Hi developer, keep building!

$result = StringMax::replaceTokensInArray([
        'Hi {{name}}, remember to be {{tip}}.',
        'Because {{myTarget}} love nice {{myTarget}}',
        'and' => [
            'the world is better if we have more {{mates}}.'
        ]
    ],
    [
        'name'      => 'developer',
        'tip'       => 'nice',
        'myTarget'  => 'people',
        'mates'     => 'friends'
    ]
);
/*
Results:
$result = [
        'Hi developer, remember to be nice.',
        'Because people love nice friends',
        'and' => [
            'the world is better if we have more friends.'
        ]
]
*/