Create a URL-safe slug
Foundation · fluency · 15 min · runtime php-cli
Brief
Implement slugify(string $title): string that lowercases, trims, replaces runs of non-alphanumeric characters with a single hyphen, and trims leading and trailing hyphens. Unicode letters should be preserved.
3 progressive hints are available in the editor.
Public checks
- lowercases and hyphenates — expected:
hello-world - collapses runs — expected:
a-b