Php – How to make the decimals superscript, or subscript, in PHP


I have this code:

<?php echo $price; ?>

which gives me this result:


Is there any way I can make the decimals superscript or subscript?


EDIT: This code works like a charm (thanks to David Thomas):

$parts = explode('.', $price); 
echo "$parts[0].<sup>$parts[1]</sup>";

but if I have a price like this: 1,500.99€ it superscripts the € sign as well. Can this be stoped? To not superscript it if it's not a number, or to superscript only 2 characters after the dot?

Best Solution

This is currently untested, but I think that's as simple as:

$parts = explode('.', $price);
echo "$parts[0].<sup>$parts[1]</sup>";