Reputation: 99
I have an input which get validated localized with float validator. How can I normalize the value via filter to store in a table which has always the same format?
Upvotes: 3
Views: 127
Reputation: 9857
NumberFormat might be useful as it includes logic for internationalization
$filter = new \Zend\I18n\Filter\NumberFormat("de_DE");
echo $filter->filter(1234567.8912346);
// Returns "1.234.567,891"
Upvotes: 5
Reputation: 565
Not sure if this is what you want. You can use a callback filter to make 5,85 to 5.85.
array(
'name' => 'Callback',
'options' => array(
'callback' => function($value) {
return str_replace(',', '.', $value);
},
),
),
You can modify it to your needs.
Upvotes: 0