Posted By

Abe on 01/30/08


Tagged

url String name nice underscore


Versions (?)

Who likes this?

19 people have marked this snippet as a favorite

adix
stphnclysmth
romanos
Dingdong
tikitakfire
not_skeletor
Vordreller
nb109
NyX
tmbrenneke
risico
ratzo
Darsain
fackz
bolven
NeekGerd
onwardonward
uberdragon
tomenjr


Underscore Strings


 / Published in: PHP
 

You can use it with 'Nice URLs' http://snipplr.com/view/4562/nice-urls-php-htaccess/

  1. <?php
  2. function string_to_underscore_name($string) {
  3. $string = preg_replace('/[\'"]/', '', $string);
  4. $string = preg_replace('/[^a-zA-Z0-9]+/', '_', $string);
  5. $string = strtolower(trim($string, '_'));
  6. return $string;
  7. }
  8. echo string_to_underscore_name("13: inside movie films```''''---\//\Bye!?");
  9. //Output: 13_inside_movie_films_bye
  10. ?>

Report this snippet  

You need to login to post a comment.