[ create a new paste ] login | about

Link: http://codepad.org/WsSncbO3    [ raw code | output | fork ]

PHP, pasted on Jan 1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php

function Slug($string)
{
	$string = htmlentities($string, ENT_QUOTES, 'UTF-8');

	if (strpos($string, '&') !== false)
	{
		$string = preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i', '$1', $string);
	}

	return strtolower(preg_replace('~[^a-z]+~i', '', html_entity_decode($string, ENT_QUOTES, 'UTF-8')));
}

var_dump(Slug('Frédér8ic@'));
var_dump(Slug('@@àbcd'));
var_dump(Slug('%*tréçd'));

?>


Output:
1
2
3
string(8) "frederic"
string(4) "abcd"
string(5) "trecd"


Create a new paste based on this one


Comments: