Cut String and add delimiter


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

It takes a String and adds a delimiter after every [length] characters.


Copy this code and paste it in your HTML
  1. function cutAt($string,$length, $delimiter){
  2. if(strlen($string) > $length)
  3. {
  4. $one = substr($string,0,$length);
  5. $two = cutAt(substr($string,$length));
  6. return $one.$delimiter.$two;
  7. }else{
  8. return $string;
  9. }
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.