PX : code

recursive add commas by reficul
Download this code


<?php
/*
*@version 1.0.0 
*@author Adam <goldlucifer@hotmail.com>
*@author your name <modify it if you have good idea>
*@var string $str
*    before you use this function,make sure the variable is a string
*    example:
*    =========================
*    $price=80000000;           // an integer
*    settype($price,"string");  // become a string
*    $price=addcomma($price);
*    echo $price;
*    =========================
*    
*/
function addcomma($str)
{
    if(
strlen($str)<=3)
    {
        return 
$str;
    }
    
$strl=substr($str,0,strlen($str)-3);
    
$return=addcomma($strl).",".substr($str,-3);
    return 
$return;    
}

?>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.