Created
October 11, 2016 04:23
-
-
Save muhfaris/5704eb04af7a40aaa5239e2d23818520 to your computer and use it in GitHub Desktop.
Konversi angka ke text, misal K dan M
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Konversi angka, | |
nah angka disini yaitu 1000 dan 1000000.. | |
untuk angka 1000 menjadi 1K | |
nah untuk 1000000 menjadi 1M | |
*/ | |
// konversi | |
function round_numb($totalshares){ | |
if( $totalshares > 1000000 ) { | |
$totalshares = round( $totalshares / 1000000, 1 ) . 'M'; | |
} elseif( $totalshares > 1000 ) { | |
$totalshares = round( $totalshares / 1000, 1 ) . 'K'; | |
} | |
return apply_filters( 'get_rounded_shares', $totalshares ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment