Skip to content

Instantly share code, notes, and snippets.

@supermethod
Created April 11, 2011 11:26
Show Gist options
  • Select an option

  • Save supermethod/913379 to your computer and use it in GitHub Desktop.

Select an option

Save supermethod/913379 to your computer and use it in GitHub Desktop.

Revisions

  1. supermethod created this gist Apr 11, 2011.
    7 changes: 7 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    function slug($str)
    {
    $str = strtolower(trim($str));
    $str = preg_replace('/[^a-z0-9-]/', '-', $str);
    $str = preg_replace('/-+/', "-", $str);
    return $str;
    }