To create a url-friendly short id from a MongoDB ObjectId, you can use the following function in PHP:
main.php473 chars12 lines
This function converts the ObjectId to a 10-character string using an alphabet of 52 characters (excluding vowels and similar characters that can be mistaken for one another).
Here's an example of how to use this function:
main.php145 chars4 lines
Note that this function will only work with MongoDB ObjectIds, and not with other types of IDs.
gistlibby LogSnag