Re: $number->precission not working in controller
> old skool php > $var 2 = number_format($var, 2); Thanks Jon this was the perfect solution! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: $number->precission not working in controller
> Still... does anyone have a suggestion for a way to make sure totaldue > is rendered in two decimal places? old skool php $var 2 = number_format($var, 2); http://uk3.php.net/manual/en/function.number-format.php jb -- jon bennett t: +44 (0) 1225 341 039 w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: $number->precission not working in controller
On 4/20/07, Joshua McFarren <[EMAIL PROTECTED]> wrote: > Still... does anyone have a suggestion for a way to make sure totaldue > is rendered in two decimal places? Huh! printf("%01.2f", $totaldue) doesn't work? T -- = PHP for E-Biz: http://sanisoft.com Cheesecake-Photoblog needs you!: http://cheesecake-photoblog.org = --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: $number->precission not working in controller
Look at phps sprintf function? Joshua McFarren wrote: >Ok, ok, I looked again at the manual and helpers are mean to provide >functions that are commonly needed in views etc. So I guess this was >stupid not easy. Also I misspelled precision in the subject AND my >corner cases are not fully checked ($,100,000.0) with that regex! > >Still... does anyone have a suggestion for a way to make sure totaldue >is rendered in two decimal places? > > >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: $number->precission not working in controller
Ok, ok, I looked again at the manual and helpers are mean to provide functions that are commonly needed in views etc. So I guess this was stupid not easy. Also I misspelled precision in the subject AND my corner cases are not fully checked ($,100,000.0) with that regex! Still... does anyone have a suggestion for a way to make sure totaldue is rendered in two decimal places? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
$number->precission not working in controller
This is probably an easy answer but I give up. Why doesn't the number helper work in my controller when it works fine in my views? class InvoicesController extends AppController { var $name = 'Invoices'; var $helpers = array('Html', 'Form', 'Javascript', 'Ajax', 'Number'); ... $totaldue = 0; foreach ($this->Invoice->findAll('status!=2', NULL, NULL) as $row) { // for each invoice thats not paid $totaldue += preg_replace("/(\\$|,)/", "", $row['Invoice'] ['total']); // turn each invoice total into a float and sum them } $this->set('totaldue', strrev(preg_replace("/(\d{3})/", "$1,", strrev($number->precision($totaldue, 2); // add commas to total and set it ... } If I change $number->precision($totaldue, 2) to just $totaldue there are no errors by the way. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---