PHP code example of donatj / printf-parser
1. Go to this page and download the library: Download donatj/printf-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/ */
donatj / printf-parser example snippets
ter = new \donatj\Printf\LexemeEmitter;
$parser = new \donatj\Printf\Parser($emitter);
$parser->parseStr('percent of %s: %d%%');
$lexemes = $emitter->getLexemes();
foreach( $lexemes as $lexeme ) {
echo $lexeme->getLexItemType() . ' -> ';
echo var_export($lexeme->getVal(), true);
if( $lexeme instanceof \donatj\Printf\ArgumentLexeme ) {
echo ' arg type: ' . $lexeme->argType();
}
echo PHP_EOL;
}