Charmland Beit el Chaar 2019

Libanon 2019 – Erinnerungen

Es war endlich soweit. Am 15.05.2019 bin ich nach 16 Jahren zum ersten Mal wieder in den Libanon geflogen. Es ging mir bei dieser Reise darum, die alten Orte, die in meiner Erinnerung eine große Rolle spielen, wieder zu besuchen.

Meine Reise in den Libanon war nur sehr kurz – ich hatte nur zwei komplette Tage und ein paar Stunden am Anreisetag zur Verfügung, so dass ich alle Orte, die ich besuchen wollte, bereits Wochen – oder sogar Monate – zuvor komplett durchgeplant hatte.

Dieser kleine Blogbeitrag soll in erster Linie dazu dienen, meine Erinnerungen für mich selbst festzuhalten. Wenn er darüber hinaus noch jemandem gefällt oder das Bild des Libanon im Kopf des Lesers etwas in ein positives Licht rückt – umso besser.

„Libanon 2019 – Erinnerungen“ weiterlesen

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.

function slugify($input, $word_delimiter='-') {
	$slug = iconv('UTF-8', 'ASCII//TRANSLIT', $input);
	$slug = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $slug);
	$slug = strtolower(trim($slug, '-'));
	$slug = preg_replace("/[\/_|+ -]+/", $word_delimiter, $slug);
	return $slug;
}

$slugString = slugify("This is just a small test for a slug creation");
echo $slugString;
// returns : this-is-just-a-small-test-for-a-slug-creation

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.

this-is-just-a-small-test-for-a-slug-creation

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