Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9137475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:06:28+00:00 2026-06-17T09:06:28+00:00

I have two types of numbers (FLOAT and BIGINT) in a mysql table. A:0.002

  • 0

I have two types of numbers (FLOAT and BIGINT) in a mysql table.

A:0.002

B: 51443234

I need to replace “.” with “,” in the numbers and I can do it by number_format

foreach ($row as $key => $val) { 
                if (is_numeric($val)) {

                        $row[$key] = number_format($val,'3', ',', '.'); }
                }
            }

new format is:

A: 0,002

B:51.443.234,000

but I don’t want the trailing zeros in number B, so I try to format FLOAT and BIGINT values separately:

foreach ($row as $key => $val) { 
                if (is_numeric($val)) {
                        if (is_float($val)) {
                        $row[$key] = number_format($val,'3', ',', '.'); }
                        else {
                        $row[$key] = number_format($val,'0', ',', '.'); }
                }
            }

but this doesn’t work.

I’m not sure where the problem is and if I can do it without converting values to string.

(I don’t know what is the disadvantage of converting to strings either..)

Can you please show the right approach?
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:06:29+00:00Added an answer on June 17, 2026 at 9:06 am

    PHP is a loosely typed language, therefore it doesn’t know about FLOATS and BIGINTS. In fact, neither 0,002 or 51.443.234 are valid values.

    For doing calculations, don’t change anything. For displaying your numbers, format them however you want, even if they’re strings.

    1. <?php
    2. $float = 2.25;
    3. $bigInt = 4235234;
    4.
    5. $commaFloat = 2,25;
    6. $commaBigInt = 4.235.234;
    7. ?>
    
    Parse error: syntax error, unexpected ',' on line 5
    

    http://codepad.org/epIuX8MZ

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two different list types. I need to remove the elements from list1
I have two types of users for my system, normal human users with a
I have two types of registration, registration A and registration B, each will have
I have two types of data sets. Both are in same size. One contains
I have two types of users on the database: -Web registered users -Twitter users
If I have two types of strings as: const char *str1 = This is
So, I have two types at the moment: const unsigned char* unencrypted_data_char; string unencrypted_data;
I am developing a application to create chart. I have two types of Queries.
I have two entities types: RunContainer parent entity type Run child entity type Run
I have two user types in my application: Investors and Advisors , they both

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.