0

I am using magento 2.2.6. I am showing the amount in particular column. of my custom page.

E.g

CASE - A

I have amount say, $100.50, I want to display amount in the following format:

00010050 (here 3 zeros should be appended before this amount and decimal format should be removed).

CASE - B

I have amount say, $1100.50, I want to display amount in the following format:

00110050 (here 2 zeros should be appended before this amount and decimal format should be removed).

Is it possible to append zeros as per amount length and show amount in such format?

  • Let me know if any issue. – Rohan Hapani Mar 13 at 11:48
2

You can use this below code :

$value = 100.50;
$padding_number = str_pad($value, 8, '0', STR_PAD_LEFT);
echo str_replace(".", "", $padding_number);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.