Skip to content

Instantly share code, notes, and snippets.

@Andrew8xx8
Created July 22, 2011 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andrew8xx8/1099275 to your computer and use it in GitHub Desktop.
Save Andrew8xx8/1099275 to your computer and use it in GitHub Desktop.
Function to convert any string to string form only letters and digits.
<?
function generate_safe_name($name, $prefix = "") {
return strtolower((empty($prefix) ? "" : $prefix . "_") . preg_replace("%[^a-zA-Z0-9]%", "_", $name));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment