Underscore Strings


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

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.