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 8187015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:25:13+00:00 2026-06-07T02:25:13+00:00

Have a text box which get data for price. If someone enter something like

  • 0

Have a text box which get data for price.
If someone enter something like “3.” i want to get it converted to “3.0”
i cannot append “0” simply in the end because then if it is “100” gets converted to “1000”

Also is_numeric(“3.”) returns 1.

Whats the possible way round?

  • 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-07T02:25:15+00:00Added an answer on June 7, 2026 at 2:25 am

    You need number_format():

    number_format('3', 1, '.', ''); // = 3.0
    number_format('3.', 1, '.', ''); // = 3.0
    number_format('3.22', 1, '.', ''); // = 3.2
    number_format('3.22abc', 1, '.', ''); // = 3.2 and a "PHP Notice:  A non well formed numeric value encountered"
    number_format('abc3.22', 1, '.', ''); // = "PHP Warning:  number_format() expects parameter 1 to be double, string given"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text box which is bound to a data service to get
i have an alert box which i want to show some icelandic text but
I have text box in which your adds values in comma separated values. Once
I have a text box which has a Ajax calendar extender attached. You click
Lets say I have a text box which should have a default value.... and
I have a text-box into which a user can input a comment. The comment
I have a web page with a read-only text box which shows some HTML
At the moment I have a slider and an small input text box which
I have a form in which i have a text box for email and
I have a program which has a text box that the user can edit.

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.