File "function.php"

Full path: /home/fsibplc/public_html/firstcash/admin/function.php
File size: 899 B (899 B bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php
/**
     * Generate Slugs from name
     */
    function generateSlug($name)
    {       
        // transliterate
        $text = iconv('utf-8', 'ISO-8859-1//TRANSLIT', $text);

        // Convert all dashes, spaces, & undescores to hyphens
        $name = str_replace(' - ', '-', $name);
        $name = str_replace('—', '-', $name);
        $name = str_replace('‒', '-', $name);
        $name = str_replace('―', '-', $name);
        $name = str_replace('_', '-', $name);
        $name = str_replace(' ', '-', $name);

        // Remove everything except 0-9, a-z, A-Z and hyphens
        $name = preg_replace('/[^A-Za-z0-9-]+/', '', $name);
        
        // Make lowercase - no need for this to be multibyte
        // since there are only 0-9, a-z, A-Z and hyphens left in the string
        $slug = strtolower($name);

        return $slug;
    }


?>