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

  • Home
  • SEARCH
  • 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 8744211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:48:31+00:00 2026-06-13T11:48:31+00:00

Possible Duplicate: How to print a number with commas as thousands separators in JavaScript

  • 0

Possible Duplicate:
How to print a number with commas as thousands separators in JavaScript

I am trying to get the value in this format, $1,000,000. Right now I am getting the value in this format, 1000000, and it’s working fine, but I don’t want this. I want it to get the value as $1,000,000 and change it in my PHP code and accept it.

My HTML:

<form action="index.php" method="Get">
    Enter the present value of pet: <input type="text" name="v" value="1000000"/><br>
    Enter the value of the pet you want: <input type="text" name="sv" value="1951153458"/><br>

    <input type="submit" />
</form>

And here is my PHP:

<?php
    $i           = 0;
    $v           = isset($_GET['v']) ? (float) $_GET['v'] : 1000000;
    $sv          = isset($_GET['sv']) ? (float) $_GET['sv'] : 1951153458;
    $petearn     = 0;
    $firstowner  = 0;
    $secondowner = 0;

    And so on..............

My calculator is working fine in this way:

http://ffsng.deewayz.in/index.php?v=1000000&sv=1951153458

But I want it to be:

http://ffsng.deewayz.in/index.php?v=$1,000,000&sv=$1,951,153,458

I’m confused anout how to change this format $1,000,000 to 1000000 this
or if there is other way. Do I need to use any JavaScript code? Before the form is submitted?

Someone tried to help me the following way, but I have no clue on how to use it.

function reverse_number_format($num)
{
    $num = (float)str_replace(array(',', '$'), '', $num);
}
  • 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-13T11:48:32+00:00Added an answer on June 13, 2026 at 11:48 am

    Just replace any non-numerical characters from the string:

    $filteredValue = preg_replace('/[^0-9]/', '', $value);
    

    UPD:

    $value = '$1,951,1fd53,4.43.34'; // User submitted value
    
    // Replace any non-numerical characters but leave dots
    $filteredValue = preg_replace('/[^0-9.]+/', '', $value);
    
    // Retrieve "dollars" and "cents" (if exists) parts
    preg_match('/^(?<dollars>.*?)(\.(?<cents>[0-9]+))?$/', $filteredValue, $matches);
    
    // Combine dollars and cents
    $resultValue = 0;
    if (isset($matches['dollars'])) {
        $resultValue = str_replace('.', '', $matches['dollars']);
        if (isset($matches['cents'])) {
            $resultValue .= '.' . $matches['cents'];
        }
    }
    
    echo $resultValue; // Result: 1951153443.34
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: how to print number with commas as thousands separators in Javascript I
Possible Duplicate: How to print number with commas as thousands separators? For example: >>
Possible Duplicate: how to print number with commas as thousands separators in Python 2.x
Possible Duplicate: JavaScript equivalent to printf/string.format How can I create a Zerofilled value using
Possible Duplicate: How to print out the method name and line number and conditionally
Possible Duplicate: How to format a decimal How can I limit my decimal number
Possible Duplicates: Don't print space after last number Printing lists with commas C++ #include
Possible Duplicate: Simple task (SVG vs. Canvas) I am trying to draw/paint a number
Possible Duplicate: Elegant workaround for JavaScript floating point number problem I would like to
Possible Duplicate: Elegant workaround for JavaScript floating point number problem Why is it that

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.