Download the PHP package mistralys/php-sprintf-parser without Composer
On this page you can find all versions of the php package mistralys/php-sprintf-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mistralys/php-sprintf-parser
More information about mistralys/php-sprintf-parser
Files in mistralys/php-sprintf-parser
Package php-sprintf-parser
Short Description Parser to find all sprintf format placeholders in a string, and get information on them.
License MIT
Informations about the package php-sprintf-parser
Sprintf format placeholders parser
PHP-based parser class that can be used to find all format placeholders of the sprintf function in a string, and get information on them.
Requirements
- PHP >= 7.4
Installation
Simply require the package via composer:
Or add it to your composer.json
manually:
Usage
Parse texts with several placeholders
Finding all formatting placeholders in a given string
can be done with the parseString()
function.
Each placeholder instance can then be used to access all relevant information on the placeholder's configuration, like its number (if any), precision, width, etc.
Parse individual formatting strings
Single placeholder format strings can also be parsed to retrieve information on the placeholder directly.
Access placeholder information
A placeholder gives access to all individual components of a format string. As the official PHP documentation for sprintf states, the format prototype looks like this:
The placeholder class allows easy access to each of these components. The following is a valid format for example, which uses all possible options.
All versions of php-sprintf-parser with dependencies
ext-mbstring Version *