Add spaces between K\'s in a number


/ Published in: PHP
Save to your folder(s)

Get number and returns a spaced string (14563 -> 14 563)


Copy this code and paste it in your HTML
  1. // Get number
  2. // Returns spaced string between Ks
  3. // ex : 14563 -> 14 563
  4. function spaceKs($n)
  5. {
  6. if (strlen($n)>3) return substr($n, 0, -3). " " . substr($n, -3);
  7. else return $n;
  8. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.