Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

remove decimal out of an equation to send to a payment gateway

Engaged ,
May 20, 2013 May 20, 2013

i have a value that currently has shows a decimal

@$amount = $_POST['amount'];

i need the decimal to show until the variable $amount is sent to the payment gateway

what is the best way to remove the decimal from the variable

so a value of e.g

250.59

will be sent as 25059

thanks

TOPICS
Server side applications
939
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
May 20, 2013 May 20, 2013

Replace decimal "." with nothing by using str_replace() funtion.

$amount = str_replace(".","",$amount);

best,

Shocker

Translate
Guest
May 20, 2013 May 20, 2013

Replace decimal "." with nothing by using str_replace() funtion.

$amount = str_replace(".","",$amount);

best,

Shocker

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 21, 2013 May 21, 2013

ok thanks

would multiplying by 100 also work?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 21, 2013 May 21, 2013

would multiplying by 100 also work?

$amount = "250.59";

echo $amount*100;

// 250.59*100 displays 25059

$amount = str_replace(".","",$amount);

echo $amount*100;

// 25059*100 displays 2505900

Your original question specifically asked how to remove a decimal, not how to multiply a variable by 100.

best,

Shocker

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 22, 2013 May 22, 2013
LATEST

yes i understand

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines