Berikut contoh sumber kode untuk fungsi separator (biasa digunakan untuk penjumlahan mata uang) :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
 
/**
 * Created by. Kohaci
 * link  : http://www.kohaci.com/
 * email : freddy(underscore)august(at)yahoo(dot)co(dot)id
*/
 
function separator($num, $suffix = '') {
 
	$ina_format_number = number_format($num, 3, ',','.');
	$result = str_replace(',000',$suffix,$ina_format_number) ;
 
	return $result ;
}
 
// How To Use
$num   = "2000000" ;
 
echo separator($num) ; // output : 2.000.000
echo separator($num,',-') ; // output : 2.000.000,- 
 
?>

Good Luck !! (^-^)/

VN:F [1.9.0_1079]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.0_1079]
Rating: 0 (from 0 votes)