PHP code example of mistralys / php-sprintf-parser
1. Go to this page and download the library: Download mistralys/php-sprintf-parser 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/ */
mistralys / php-sprintf-parser example snippets
use function Mistralys\SprintfParser\Functions\parseString;
$parser = parseString('The price of product %1$s has been set to %2$.2d EUR.');
$placeholders = $parser->getPlaceholders();
use function Mistralys\SprintfParser\Functions\parseFormat;
$placeholder = parseFormat('%1$.2d');
use function Mistralys\SprintfParser\Functions\parseFormat;
$placeholder = parseFormat("%1$+-0'*4.3d");
$placeholder->getSpecifier(); // s
$placeholder->getNumber(); // 1
$placeholder->getWidth(); // 4
$placeholder->getPrecision(); // 3
$placeholder->getPaddingChar(); // *
$placeholder->hasPlusMinusPrefix(); // true
$placeholder->hasLeftJustification(); // true
$placeholder->hasOnlyZeroLeftPadding(); // true
composer
json
{
"tralys/php-sprintf-parser": "^1.0"
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.