1

I want to separate the price and decimals, to use this html for the price 49,95.

<span class="price">
49,
<span class="price-decimal"> 95 </span>
</span>

I currently use this line to load the price:

<?php echo substr($_product->getPrice(), 0, -2) ?>

How can I fix that?

1
  • off topic, purely php question. Commented Jan 22, 2015 at 18:41

2 Answers 2

1

$first_amount_before_split = 29.95;

$my_array = explode(".", $first_amount_before_split);

echo $my_array[0]; // would be 29

echo $my_array[1]; // would be 95

1
  • :D glad to help! Commented Jan 22, 2015 at 18:57
1

You may use search and look here: https://stackoverflow.com/questions/6518454/how-to-split-float-in-php price is of float type in Magento.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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