Solved

setlocale(LC_MONETARY, 'en_US'); not working on ubuntu 12.4

Posted on 2013-12-05
6
1,048 Views
Last Modified: 2013-12-05
I have some php code displaying car prices. I'm using setlocale(LC_MONETARY, 'en_US'); to format the prices. Now this code works on my site hosted by Hostmonster, but on my ubuntu server this is not working. What could be the problem?

I forgot to add that this is not working either: money_format('%.0n' ,$row['InternetPrice']);
0
Comment
Question by:rraymond1130
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39698300
not working

Have you seen this link on the man page?
http://php.net/manual/en/function.money-format.php#86039

This also looks promising:
http://manpages.ubuntu.com/manpages/intrepid/man3/setlocale.3.html

Is there a symptom of failure that you might be able to share?  Is there a code example?  

Thanks, ~Ray
0
 

Author Comment

by:rraymond1130
ID: 39698330
Here is the code that is being used below. It works on the site hosted by hostmonster which is a Linux server. I figured it would work on a ubuntu server also since its Linux. No errors being reported:

setlocale(LC_MONETARY, 'en_US'); //Set Currency to US. This will put a $ in front of the number
$intPrice = money_format('%.0n' ,$row['InternetPrice']); //This sets the format for the dollar amount to $##,### no cents

I get a feeling their may be a package that needs to be installed on ubuntu but don't know which.
0
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39698337
http://manpages.ubuntu.com/manpages/intrepid/man3/setlocale.3.html

I think you may need something like 'en_US.UTF-8' in setlocale()
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39698420
Testing on my server, both en_US and en_US.UTF-8 worked correctly.

<?php // RAY_temp_rraymond1130.php
error_reporting(E_ALL);
echo "<pre>";

// SEE http://www.experts-exchange.com/OS/Linux/Q_28311139.html

$x = setlocale(LC_MONETARY, 'en_US.UTF-8');
var_dump($x);

$row['InternetPrice'] = '1234.56';
$y = money_format('%.0n' ,$row['InternetPrice']);
var_dump($y);

Open in new window

0
 

Author Closing Comment

by:rraymond1130
ID: 39698422
As usual Ray, Great Help!!!! Thanks
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39698447
Thanks for the points and thanks for using EE! ~Ray
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question