Advertisement
fauzanjeg

Short Format Number

Jul 19th, 2021
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1. function jnews_meta_views( $post_id = null, $range = null, $number_format = true ) {
  2.     $total = apply_filters( 'jnews_get_total_fake_view', 0, $post_id );
  3.     return jnews_number_format( $total );
  4. }
  5.  
  6. function jnews_number_format( $total ) {
  7.     if ( $total > 1000000 ) {
  8.         $total = round( $total / 1000000, 1 ) . 'M';
  9.     } elseif ( $total > 1000 ) {
  10.         $total = round( $total / 1000, 1 ) . 'k';
  11.     }
  12.     return $total;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement