PHPackages                             teamdigivotion/format - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. teamdigivotion/format

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

teamdigivotion/format
=====================

Library for string formatting.

1.1.1(4y ago)027UnlicensePHPPHP ^7.0

Since Mar 12Pushed 2y agoCompare

[ Source](https://github.com/TeamDigivotion/php-format)[ Packagist](https://packagist.org/packages/teamdigivotion/format)[ RSS](/packages/teamdigivotion-format/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (3)Versions (4)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/ab2cc16998370729fcfd8ba2670765db3ffc7e6ba8db58e77a133eddf5494d87/68747470733a2f2f706f7365722e707567782e6f72672f666c6573686772696e6465722f666f726d61742f762f737461626c65)](https://packagist.org/packages/fleshgrinder/format)[![License](https://camo.githubusercontent.com/6d460f3fdf9cdea70db36eb2a9e25cf69010f4e245387ca360e0fca478f12400/68747470733a2f2f706f7365722e707567782e6f72672f666c6573686772696e6465722f666f726d61742f6c6963656e7365)](https://packagist.org/packages/fleshgrinder/format)[![Travis CI build status](https://camo.githubusercontent.com/95b68db4b0c6bdc4d759ff639093e8bdb5db414992f92a424ccadd581b2c286f/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f466c6573686772696e6465722f7068702d666f726d61742e737667)](https://travis-ci.org/Fleshgrinder/php-format)[![AppVeyor CI build status](https://camo.githubusercontent.com/0f9b786fa9f140b01b25b9560989d170401ec58e1254df7ba3740f90c55d8356/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f333670626e647132653733396c6c70312f6272616e63682f6d61737465723f7376673d74727565)](https://ci.appveyor.com/project/Fleshgrinder/php-format/branch/master)

[![Dependency Status](https://camo.githubusercontent.com/558f1dcfe8726c98bfcee7885dab26c59f0e6b53ec8fb25463cd30005e7823ca/68747470733a2f2f67656d6e617369756d2e636f6d2f6261646765732f6769746875622e636f6d2f466c6573686772696e6465722f7068702d666f726d61742e737667)](https://gemnasium.com/github.com/Fleshgrinder/php-format)[![Coveralls branch](https://camo.githubusercontent.com/75cb6e0c69f8525b8ceb03e0e572969b4fb05ae74619e196a29bec81078a2533/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f466c6573686772696e6465722f7068702d666f726d61742f6d61737465722e737667)](https://coveralls.io/github/Fleshgrinder/php-format)[![Scrutinizer](https://camo.githubusercontent.com/065baf2c7a76736c240dd90615274a1e15043a62b28aabb4407bb6a2b64e7575/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f466c6573686772696e6465722f7068702d666f726d61742e737667)](https://scrutinizer-ci.com/g/Fleshgrinder/php-format/)[![Code Climate: GPA](https://camo.githubusercontent.com/bfa9123f2d4fb3925ac60fc99675a99537fa5d3849ffc41650debdf05662e897/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6769746875622f466c6573686772696e6465722f7068702d666f726d61742e737667)](https://codeclimate.com/github/Fleshgrinder/php-format)[![Total Downloads](https://camo.githubusercontent.com/bddb32a1fdd17b3f0dd9206602e11df9ad8895b8ab3a36adab461a081fbed693/68747470733a2f2f706f7365722e707567782e6f72672f666c6573686772696e6465722f666f726d61742f646f776e6c6f616473)](https://packagist.org/packages/fleshgrinder/format)

Format
======

[](#format)

The **format** library provides the functionality to format special string patterns. The implementation is similar to [`sprintf`](https://php.net/sprintf)and [`msgfmt_format_message`](https://php.net/messageformatter.formatmessage)but with various unique and very useful features.

- [Installation](#installation)
- [Usage](#usage)
    - [Placeholders](#placeholders)
    - [Type Modifier](#type-modifier)
    - [String Formatting and Modifiers](#string-formatting-and-modifiers)
    - [Number Formatting and Modifiers](#number-formatting-and-modifiers)
    - [Iterable Listings and Modifiers](#iterable-listings-and-modifiers)
    - [Optional Parts](#optional-parts)
    - [Escaping](#escaping)
    - [Errors and Exceptions](#errors-and-exceptions)
- [Testing](#testing)

Installation
------------

[](#installation)

Open a terminal, enter your project directory and execute the following command to add this library to your dependencies:

```
composer require fleshgrinder/format
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md) of the Composer documentation.

Usage
-----

[](#usage)

This library features a single static method to format string patterns. Some examples of the format method are:

```
