Skip to content

Instantly share code, notes, and snippets.

@cha0s
Created July 12, 2012 21:30
Show Gist options
  • Save cha0s/3101161 to your computer and use it in GitHub Desktop.
Save cha0s/3101161 to your computer and use it in GitHub Desktop.
<?php
function transform_name($name) {
// Always remove .php.
$name = str_replace('.php', '', $name);
// Replace any non alphanumeric characters with '-'.
$name = preg_replace("[^a-zA-Z0-9", "-", $name);
return $name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment