<?php
function createSlug($string)
{
    $slug = strtolower(trim($string));
    $slug = preg_replace('/[^a-z0-9-]/', '-', $slug); // Replace non-alphanumeric with dashes
    $slug = preg_replace('/-+/', '-', $slug); // Replace multiple dashes with a single dash
    return rtrim($slug, '-');
}