[Solved] Convert .5 into 1/2


PHP code demo(In HTML it will work fine)

<?php
$number="10.5000";
if(preg_match("/^[1-9][0-9]*\.5[0]{0,}$/", $number))
{
    echo $used = preg_replace("/\.5[0]{0,}$/", "&frac12;", $number);
}
elseif(preg_match("/^[0]*\.5[0]{0,}$/", $number))
{
    echo $used = str_replace("$number", "&frac12;", $number);
}
else
{
    echo $number;
}

Output:
10½

14

solved Convert .5 into 1/2