View Single Post
Old 02-03-2012, 09:56 AM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,359
best way to generate a random string?

looking to create a string like on pastebin for the entries.

whats the best way to go about this?

current way im doing is using uniqid with some other jazz

Code:
function short_name( $post_name ) {
                global $wpdb, $post;
                if ( !is_object( $post ) )
                        return $post_name;
                $num    = (int) $post->ID;
                $pasteid = md5(uniqid($num, true));
                $slug = dechex(crc32($pasteid));
                return $slug;
 }
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote