This is the conversion method used by evil walrus to convert script titles to URL titles. Removes all special characters, except hyphens, underscores, periods, commas and forward slashes, which are converted to underscores. Two or more consecutive underscores are converted to a single underscore.
<?php
// written by Aaron Hall, evilwalrus.org
// free to use, modify and redistribute without notification
$title = "This is a script -- uses PHP/MySQL! __cool!__ ";
$title = ereg_replace("[^A-Za-z0-9_\-\./, ]", "", $title); // remove special characters
$title = str_replace(array('.','-','/',','), " ", $title); // replace legal characters with spaces
$title = trim($title); // remove leading and trailing whitespace
$title = ereg_replace(" {1,}", "_", $title); // convert one or more consecutive spaces to a single underscore
$title = ereg_replace("_{2,}", "_", $title); // convert two or more consecutive underscores to a single underscore
echo $title;
// prints "This_is_a_script_uses_PHP_MySQL_cool";
?>
<?php
// written by Aaron Hall, evilwalrus.org
// free to use, modify and redistribute without notification
$title = "This is a script -- uses PHP/MySQL! __cool!__ ";
$title = ereg_replace("[^A-Za-z0-9_\-\./, ]", "", $title); // remove special characters
$title = str_replace(array('.','-','/',','), " ", $title); // replace legal characters with spaces
$title = trim($title); // remove leading and trailing whitespace
$title = ereg_replace(" {1,}", "_", $title); // convert one or more consecutive spaces to a single underscore
$title = ereg_replace("_{2,}", "_", $title); // convert two or more consecutive underscores to a single underscore
echo $title;
// prints "This_is_a_script_uses_PHP_MySQL_cool";
?>