Hey,
I have a function that converts my money into gold, silver and copper. (code below) I was wondering if there is a way to make it so if there is 0 copper and\or silver it'd make it not show it. (IE: 200gold 300 silver 000copper make it look like this, 200gold 300 silver) Thanks for the help in advance
function gold_format($money)
{
$counter=strlen($money);
if ($counter <= 3)
{
$moneydone="
$money<img src='images/Copper.png'/>";
return $moneydone;
}
if ($counter <= 6)
{
$copper= substr($money, -3);
$silver= substr($money, 0, -3);
$moneydone="
$silver<img src='images/Silver.png'/>
$copper<img src='images/Copper.png'/>";
return $moneydone;
}
else
{
$copper= substr($money, -3);
$mid=($counter-6);
$silver= substr($money, $mid, -3);
$gold=substr($money, 0, $mid);
$moneydone="
$gold<img src='images/Gold.png'/>
$silver<img src='images/Silver.png'/>
$copper<img src='images/Copper.png'/>";
return $moneydone;
}
}



Reply With Quote


Bookmarks