3

I have a value like 12,25,246 I want to get 1225246 (must be an integer)

How can I do that?

I have searched a lot but there are direct answer like converting string to integer but not like this actually these both are like integer

I have tried php formate_number but it did not worked.

5
  • It already answered, You will get it in more details over there: stackoverflow.com/questions/8529656/… Commented Mar 24, 2020 at 11:46
  • It's not the same. @Rajon Commented Mar 24, 2020 at 11:47
  • @Rajon The question is slightly different than the one you linked. Here the value has multiple commas and is not in a common numerical format. Commented Mar 24, 2020 at 11:49
  • 1
    Show us how you tried to solve the problem yourself, then show us exactly what the result was, and tell us why you feel it didn't work. Give us a clear explanation of what isn't working and provide a Minimal, Complete, and Verifiable example. Read How to Ask a good question. Be sure to take the tour and read this. Commented Mar 24, 2020 at 12:34
  • It is in JavaScript @MarkusZeller Commented Mar 24, 2020 at 13:12

2 Answers 2

6

You could use a combination of intval() and str_replace() to do this.

Example:

$value = '12,25,246'; var_dump(intval(str_replace(',','',$value))); // Yields: "int(1225246)" 

Sandbox

Sign up to request clarification or add additional context in comments.

Comments

1
$number = (int)str_replace(',', '', '12,25,246'); 

here is it

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.