All pastes #710182 Raw Edit

Unnamed

public text v1 · immutable
#710182 ·published 2007-09-25 09:17 UTC
rendered paste body
function makeUrlSafeTitle($v_title)
{
	$title= strtolower($v_title);
	$len = strlen($title);
	//change all none url chars to spaces
	for($i=0;$i<$len;$i++)
	{
		$letter = substr($title, $i, 1);
		preg_match('/[-0-9a-z]/', $letter, $matches);
		$spaceString .= (preg_match('/[-0-9a-z]/', $letter)) ? $letter : " ";
	}
	//replace all the spaces and excess spaces with one of these -
	$newstring = preg_replace('/\s\s+/', '-', $spaceString);
	$newstring = preg_replace('/ /', '-', $newstring);
	return $newstring;
}