PHP URL Shortening Algorithm

后端 未结 7 910
说谎
说谎 2020-12-28 09:22

Could anyone recommend a preferred algorithm to use for URL shortening? I\'m coding using PHP. Initially I thought about writing something that would start at a character su

7条回答
  •  情书的邮戳
    2020-12-28 09:36

    i used to break ID by algorithm similar with how to convert from decimal to hex, but it will use 62 character instead of 16 character that hex would use.

    '0','1','2','3','4','5','6','7','8','9',
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
    'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
    

    example : if you will change ID = 1234567890 you will get kv7yl1 as your a key.

提交回复
热议问题