[eluser]dbashyal[/eluser]
[quote author="Johan André" date="1237311450"]Nice!
But what's wrong with the url_title() from the url-helper included in CI?[/quote]
haha i had no idea too that it existed so i end up making this function to achieve that result for my CMS codefight.:
Code:
/*
* Create and return clean url segment
*/
function link_clean($segment = false)
{
/*
* START: Clean Segment
*/
$segment = preg_replace('|[^a-z0-9]+|i','-',strtolower($segment));
//remove last dashes if any
while(substr($segment, -1) == '-') {
$segment = substr($segment, 0, -1);
}
//remove first dashes if any
while(substr($segment, 0, 1) == '-') {
$segment = substr($segment, 1);
}
/*END: Clean Segment*/
return $segment;
}
But the question is which is faster