geosocio/slugger

Creates URL Slugs from Strings


Keywords
php
License
Other

Documentation

Slugger Build Status Coverage Status

Create URL Slugs From UTF-8 Strings

Rules

  1. Trim Whitespace
  2. Lowercase (if possible)
  3. Replace (space) with - (dash)
  4. Remove ., (, and )
  5. Remove any duplicate - (dashes)
  6. Trim any - (dashes) from the beginning or end

Example

$slugger = new \GeoSocio\Slugger\Slugger();
echo $slugger->slug('St. Petersburg');
// st-petersburg

See more examples in tests/SluggerTest.php