PHP-Function: Create slugs from string

Every website needs to implement readable URLs for internal linking. When you are using a blogging tool like WordPress or a CMS like Typo3, you automatically get the URL slug generator built in.

But sometimes, you are developing your own software and are in need of a function that simply generates a slug for you.


Search no more, because here it is: the PHP function to generate slugs for you.

This PHP function takes a simple string as first parameter, which will be turned into your slug. In this example, we are using the string  This is just a small test for a slug creation .

The function slugify  then returns a nice, readable slug for you.

If you want to use another delimiter, simply pass it as the second parameter to the function.

 

PHP-Function: Create slugs from string
Wie bewertests Du diesen Beitrag? Rate this postplease.

Kommentar verfassen