oodle/urlify

urlify - a library for creating url-safe slugs from text

dev-master 2013-11-30 06:00 UTC

This package is auto-updated.

Last update: 2020-03-18 07:01:39 UTC


README

Urlify is a library for creating url-safe slugs from text. It will also down-convert (Romanize) foreign ascii characters into plain ascii.

Installation:

Add this line to your composer.json "require" section:

composer.json

    "require": {
       ...
       "oodle/urlify": "*"

Usage:

Urlify\Urlify::urlify($string, $separator = '-', $ampersand = null)

Examples:

use Urlify\Urlify;

echo Urlify::urlify('blah blah blah'); // Should output "blah-blah-blah"

echo Urlify::urlify('This is a sentence.'); // Should output "This-is-a-sentence"

echo Urlify::urlify('kraüt'); // Should output "kraut"

echo Urlify::urlify('what ever', '.'); // Should output "what.ever"

echo Urlify::urlify('blah&blah'); // Should output "blah-blah"

echo Urlify::urlify('blah&blah', '-', 'and'); // Should output "blah-and-blah"


Notes:
------
Please note that the string should be in ascii or iso-8859-1 in order for Romanization to work