PhpRiot
Follow phpriot on Twitter
Sponsored Link
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store
Free iPad/iPhone App
Available on the App Store

  • PHP manual
  • Zend Framework manual
  • Smarty manual
  • PHP articles
  • PHP training

Working with currency values

The currency value, a.k.a. the money, you want to use can easily be set by using the value option.

<?php
$currency 
= new Zend_Currency(
    array(
        
'value'    => 1000,
        
'currency' => 'USD',
    )
);

print 
$currency// Could return '$ 1.000'

Using the setFormat() method with this array option, and also by using the setValue() method you can set the value afterwards.

<?php
$currency 
= new Zend_Currency(
    array(
        
'value'    => 1000,
        
'currency' => 'USD',
    )
);

print 
$currency->setValue(2000); // Could return '$ 2.000'

With the getValue() method you will get the actual set value.

Zend Framework