Return to Snippet

Revision: 4952
at January 30, 2008 14:30 by Abe


Initial Code
<?php
	function string_to_underscore_name($string) {
	    $string = preg_replace('/[\'"]/', '', $string);
	    $string = preg_replace('/[^a-zA-Z0-9]+/', '_', $string);
	    $string = strtolower(trim($string, '_'));
	    return $string;
	}
	echo string_to_underscore_name("13: inside movie films```''''---\//\Bye!?");
	//Output: 13_inside_movie_films_bye
?>

Initial URL


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

Initial Title
Underscore Strings

Initial Tags
url

Initial Language
PHP