Short unique id in php

前端 未结 16 978
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 17:34

I want to create a unique id but uniqid() is giving something like \'492607b0ee414\'. What i would like is something similar to what tinyurl gives:

16条回答
  •  萌比男神i
    2020-11-29 18:06

    You can achieve that with less code:

    function gen_uid($l=10){
        return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyz"), 0, $l);
    }
    

    Result (examples):

    • cjnp56brdy
    • 9d5uv84zfa
    • ih162lryez
    • ri4ocf6tkj
    • xj04s83egi

提交回复
热议问题