if the last four numbers are always the number of silver coins and bronze coins, and the remaining numbers denote how many gold coins there are, you can use the substr() function to break it up. I made this example:
PHP Code:
<?php
//returns 20000,00,00
echo convertCoins(200000000) . "\n\n";
//returns 2,00,00
echo convertCoins(20000) . "\n\n";
//returns 2
echo convertCoins(2) . "\n\n";
function convertCoins($n){
$l = strlen($n);
$coins = array();
//are there enough coins to show gold?
if($l > 4){
//gold
$coins[] = substr($n, 0, -4); //start at the beginning and go until the fourth-last character
}
//are there enough coins to show silver?
if($l > 2){
//silver
$coins[] = substr($n, -4, 2); //start at the fourth-last character and stop 2 characters later
}
//always calculate bronze
//bronze
$coins[] = substr($n, -2); //start at the second-last character and go until the end
return implode($coins, ",");
}
?>
there could be many additions made to suit this to more specific needs, but it should give you a general idea. ask questions if you need help.