Posted By

jspicher on 10/09/09


Tagged

php search text function engine urls safe stringtounderscore SE


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

NeekGerd


string_to_underscore($string)


 / Published in: PHP
 

Convert string to underscore, for SE safe URLs etc.

  1. function string_to_underscore($string){
  2. $string = preg_replace('/[\'"]/', '', $string);
  3. $string = preg_replace('/[^a-zA-Z0-9]+/', '_', $string);
  4. $string = trim($string, '_');
  5. $string = strtolower($string);
  6. return $string;}

Report this snippet  

You need to login to post a comment.