Slug

public function slug($title) { $a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜüÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ"!@#$%&*()_-+={[}]/?;:,\\\'<>'; $b = 'aaaaaaaceeeeiiiidnoooooouuuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr '; $string = utf8_decode($string); $string = strtr($string, utf8_decode($a), $b); $string = strip_tags(trim($string)); $string = preg_replace('/\s(?=\s)/', '', $string); $string = preg_replace('/[\n\r\t]/', ' ', $string); $string = str_replace(" ","-",$string); $string = strtolower(utf8_encode($string)); $words = explode(' ', strtolower($string)); $url = ''; $total = 0; foreach ($words as $value) { ++$total; $url .= $value . '-'; } $url = substr($url, 0, strlen($url) - 1); $url = str_replace(',', '', str_replace('--', '-', $url)); return $url; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.