note 47634 deleted from function.chunk-split by nlopess
| From: | nlopess@php.net | Date: | Fri, 11 Mar 2005 23:34:12 +0000 |
| Subject: | note 47634 deleted from function.chunk-split by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-86309@lists.php.net to get a copy of this message | ||
Note Submitter: Dimitri
----
If you need the chunks to be split from the right, you can use the following function:
<? function chunk_split_right($str,$len=3,$delim=',') {
$size = strlen($str);
if( $size <= $len ) return $str;
return (chunk_split_right(substr($str,0,$size-$len),$len,$delim).
$delim.substr($str,$size-$len,$len));
}
?>
This is useful for formating large numbers into human readable strings, e.g.
<? echo chunk_split_right(1234567890); ?>
=> 1,234,567,890