We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

number_format (php) in volt

Hello! How in the Volt output format a number with a partition of the groups (1000 -> 1 000)?

edited Mar '17


First, you need to register a filter (see https://docs.phalcon.io/en/latest/reference/volt.html#id2)

$compiler->addFilter('number_format', 'number_format');

Then you need to call this filter like this:

{{  1000|number_format(0, '.', ' ') }}

NOTE: Use those arguments for number_format that are necessary for your task (see https://php.net/number_format)

edited Mar '17

Thank you. Where should I register the filter? In service.php or in the controller? While I receive an error Unknown filter "number_format"

Where you define view service.

edited Mar '17

Registered in service.php in protected function initSharedVolt