stublackett Posted September 21, 2009 Share Posted September 21, 2009 Hi guys, Hopefully a quick and simple answer... I've got a shopping cart script setup. I'm doing the function number_format to add two decimals points after a variable, But what I need to know is how do I echo out the "£" sign into the code. As currently it shows the right amount, Just without the "£" sign appearing. Here is my code <?php $subtotal = $quantity * 45.00; $vat = ($subtotal + 3) * 0.15 ; $vat = number_format($vat,2); $total = $vat+ $subtotal + 3; $total = number_format($total,2); ?> Where there is a number_format I need to add the "£" sign Thanks again Link to comment https://forums.phpfreaks.com/topic/174997-solved-showing-a-%C2%A3-sign/ Share on other sites More sharing options...
MadTechie Posted September 21, 2009 Share Posted September 21, 2009 $total = "£".$total; or $total = "£".$total; maybe use the money_format(), ie setlocale(LC_MONETARY, 'en_GB'); $total = money_format('%n', $total); Link to comment https://forums.phpfreaks.com/topic/174997-solved-showing-a-%C2%A3-sign/#findComment-922298 Share on other sites More sharing options...
stublackett Posted September 21, 2009 Author Share Posted September 21, 2009 Excellent... Thanks Link to comment https://forums.phpfreaks.com/topic/174997-solved-showing-a-%C2%A3-sign/#findComment-922301 Share on other sites More sharing options...
Guest Posted March 18, 2010 Share Posted March 18, 2010 Hi there, I have a question about the money_format() function. I am trying to use it on a website I'm building at the moment and I have a problem with it. Here is the code I use: setlocale(LC_MONETARY, 'en_GB'); echo money_format('%.0n',$list['price'])."\n"; On my local server, I have no problem, the amount and symbol appear correctly. But when I upload the files on an online testing server, the "£" does not appear and leaves a question mark in a black diamond. Can anyone tell me what I am doing wrong? Thanks in advance. Cheers, Link to comment https://forums.phpfreaks.com/topic/174997-solved-showing-a-%C2%A3-sign/#findComment-1028071 Share on other sites More sharing options...
Guest Posted March 18, 2010 Share Posted March 18, 2010 Hi again, I found a solution to my problem. I changed the code to: setlocale(LC_MONETARY, 'en_GB.UTF-8'); echo money_format('%.0n',$list['price'])."\n"; Now it works properly. Hope that helps some people too. Cheers, Link to comment https://forums.phpfreaks.com/topic/174997-solved-showing-a-%C2%A3-sign/#findComment-1028128 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.