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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:20:58+00:00 2026-05-25T06:20:58+00:00

I have an amount like 0003000 , the last 2 digits are the decimal

  • 0

I have an amount like 0003000, the last 2 digits are the decimal number. I want to transform 0003000 to 00030,00 (insert a decimal comma in front of the last 2 digits).
I tried to do this with substring. I take the length of the string with strlen and then I make -2, but it ignores the -2.

Here is an example, why is it being ignored?

substr($this->arrCheck['amountsum'],0,(strlen($this->arrCheck['amountsum']-2)))
  • 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-05-25T06:20:58+00:00Added an answer on May 25, 2026 at 6:20 am

    It’s because your -2 is in the strlen function instead of outside it:

    strlen($this->arrCheck['amountsum']-2)
    

    Should be:

    strlen($this->arrCheck['amountsum'])-2
    

    But all in all you don’t need to use strlen, since substr accepts a negative number as number of characters before the end of the string: PHP Manual

    So your whole code above can be replace by:

    substr($this->arrCheck['amountsum'], 0, -2)
    

    And the whole thing can be achieved by:

    substr($this->arrCheck['amountsum'], 0, -2).','.substr($this->arrCheck['amountsum'], -2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In each table have many number of rows with amount. Like this i have
I have a string that shows a number with a comma separator like this:
I have a query like this: SELECT COUNT(*) AS amount FROM daily_individual_tracking WHERE sales
I have a MySQL query like this: SELECT DAYNAME(CreatedAt) AS TheDay, SUM(Amount) AS TheSum
I have a NSThread that i would like to timeout after a certain amount
I have 2 columns Name and Amount I like the linq to return the
I have a good amount of code which looks like this: rule requestIntHoleTemplate {
if I have a structure like this: Batch Amount 76 495.4 76 975.75 76
I have n amount of tds inside of 1 tr. I would like to
I have an invoice table like this: Bill Item Qty Weight Rate Amount Advance

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.