welcome to runtings.com

Using money_format() with Windows PHP

Here is a little workaround for those of you that have windows boxes and are using code that already makes use of the money_format() function.

My code was only using it to format money figures visually, so I cant vouch for it when performing calculations with it. Also all the money_format() calls in the code im working with were of the form money_format('%4n', $variable_name); and I am working with GBP currency.

To be honest I only have a vague idea of what I did, but it has the required visual pay off except for the fact you lose the comma's from large figures.

To use it just put the snippet into a header file or the main php file before the first time money_format would be called.

<?php
 if(!function_exists('money_format'))
 {
	function money_format($format, $number)
    {
        return '£' . sprintf("%01.2f", $number);
    }
 }
?>

Network

rtpDesign

www.rtpdesign.co.uk

professional web development

rtpSoftware

www.rtpsoftware.co.uk

free software

 

rtp|designrtp|software