Copy link to clipboard
Copied
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
Replace decimal "." with nothing by using str_replace() funtion.
$amount = str_replace(".","",$amount);
best,
Shocker ![]()
Copy link to clipboard
Copied
Replace decimal "." with nothing by using str_replace() funtion.
$amount = str_replace(".","",$amount);
best,
Shocker ![]()
Copy link to clipboard
Copied
ok thanks
would multiplying by 100 also work?
Copy link to clipboard
Copied
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 ![]()
Copy link to clipboard
Copied
yes i understand
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more