Posted By

rombob on 08/23/09


Tagged

url String clean


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


string to url compatible


 / Published in: PHP
 

remove multiple spaces and replace with underscore

  1. function stringUrlFormat($str){
  2. $underscore = chr(95);
  3. $space = chr(32);
  4. // compress multiple spaces
  5. $count = 1;
  6. while($count){
  7. $str = str_replace(' ', $space, $str, $count);
  8. }
  9.  
  10. $str = str_replace($space, $underscore, $str);
  11. return $str;
  12. }

Report this snippet  

You need to login to post a comment.