Plugin

Archived
Forum
(read-only)

Will Hunting

ExpressionEngine 1.x, ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Isaac Raway

     

decimal=“2”?

Feature Request

T2theC
T2theC

Hi ya Ryan,

Fantastic add-on. Thanks ver much.

I am needing to show a result with two decimal places.  I take it this isn’t possible at the moment? Do you think it might be something you would look to add in the near future?

Many thanks,

MetaSushi
# 1
Developer
MetaSushi

Try opening up pi.will_hunting.php, and around line 429 add the last line shown here to the array:

var $functions = array(
            
'abs'           => array('abs'1),
            
'ceil'          => array('ceil'1),
            
'floor'         => array('floor'1),
            
'int'           => array('intval'1),
            
'max'           => array('max', -1),
            
'min'           => array('min', -1),
            
'rand'          => array('rand'2),
            
'round'         => array('round'1,2),
            
'mod'           => array('wh_mod',2),
            
'sqrt'           => array('sqrt',2),
            
'number_format' => array('number_format'2),
    ); 

You should then be able to call the number_format function from Will Hunting. Let me know how it works.

My name is actually Isaac, btw :-p

T2theC
# 2
T2theC

Ah! Where did I get Ryan from? Must have been one of those days. Sorry Isaac - I did know that. Big fan of your work.

I will give that a bash and report back. Thanks so much for the advice.

MetaSushi
# 3
Developer
MetaSushi

Thanks for the kind words. :) Let me know how it goes.

GabbaTheHutt
# 4
GabbaTheHutt

Hi Isaac

I hope this doesn’t sound dumb, but how do you call the number_format function? could you give me an example?

Cheers
Gabber

GabbaTheHutt
# 5
GabbaTheHutt

OK so I have worked it out… it was simple once I read the instructions properly:

number_format(1.2345, 2) gives 1.23

The only problem is that I want 1.2 to display as 1.20 for currencies, but it displays as 1.2. Is there anything that can be done about this?

Great little plugin otherwise :-)