Posted By

dhjapan on 09/29/11


Tagged

php


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tux-world


Add spaces between K's in a number


 / Published in: PHP
 

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

  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  

You need to login to post a comment.