geosocio/slugger

Creates URL Slugs from Strings

1.1.2 2018-01-26 00:51 UTC

This package is auto-updated.

Last update: 2024-04-12 00:15:43 UTC


README

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