Return to Snippet

Revision: 49106
at July 16, 2011 00:17 by Josh


Initial Code
function str_inc($str, $pos = 0)
{
	$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_';
	$charsmax = strlen($chars);
	$len = strlen($str);
	if($len == 0)
	{
		return $chars[0];
	}
	$strindex = $len - $pos - 1;
	if($strindex < 0)
	{
		return $chars[0] . $str;
	}
	$char = $str[$strindex];
	$charsindex = strpos($chars, $char);
	if($charsindex == $charsmax)
	{
		$str[$strindex] = $chars[0];
		return str_inc($str, $pos + 1);
	}else{
		$str[$strindex] = $chars[$charsindex + 1];
		return $str;
	}
}

Initial URL

                                

Initial Description

                                

Initial Title
URL Shortener Generator.

Initial Tags

                                

Initial Language
PHP