Skip to content

Instantly share code, notes, and snippets.

@mahmoud
Created January 3, 2010 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmoud/267835 to your computer and use it in GitHub Desktop.
Save mahmoud/267835 to your computer and use it in GitHub Desktop.
function nextID($id) {
$avail_chars = $this->config->item('link_id_chars'); //a string, no dupe chars plz.
if($id === '') {
return $avail_chars[0];
} else if($id[strlen($id)-1] === $avail_chars[strlen($avail_chars)-1]) {
return $this->nextID(substr($id, 0, -1)).$avail_chars[0];
} else {
return substr($id, 0, -1).$avail_chars[strrpos($avail_chars,$id[strlen($id)-1])+1];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment