PHP code example of victoryoalli / laravel-string-macros
1. Go to this page and download the library: Download victoryoalli/laravel-string-macros 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/ */
victoryoalli / laravel-string-macros example snippets
use Illuminate\Support\Str;
// Static usage - multiple arguments
Str::interpolate('Roses are ? Violets are ?', 'RED', 'BLUE');
// "Roses are RED Violets are BLUE"
// Static usage - array
Str::interpolate('Roses are ? Violets are ?', ['RED', 'BLUE']);
// "Roses are RED Violets are BLUE"
// Static usage - spread operator
Str::interpolate('Roses are ? Violets are ?', ...['RED', 'BLUE']);
// "Roses are RED Violets are BLUE"
// Fluent usage
Str::of('Hello ? and ?')->interpolate(['World', 'Universe'])->toString();
// "Hello World and Universe"
use Illuminate\Support\Str;
// Static usage
Str::readingMinutes('Your long article text here...');
// 1
// With custom words per minute
Str::readingMinutes($longText, 150);
// 3
// Fluent usage
Str::of('<p>HTML content</p>')->readingMinutes()->toString();
// "1"