Hello, I would use something like this.
I will explain a little but of what is going on within the function.
The first line in the function which returns $string simply uses str_replace to remove the underscore, if you want to leave the possibility of including the underscore this line would then simply look like this:
PHP Code:
$string = str_shuffle($post_type);
The second line just grabs the characters of the shuffled string, the length of which is determined by the size of the limit parameter. The next line appends the digits to the create the desired string. Hope this helps.
PHP Code:
<?
$post_type = 'os_fashion';
$post_id = 23456;
function generate_random_output($post_type, $post_id, $limit = 2)
{
$string = str_shuffle(str_replace('_', '', $post_type));
$output = substr($string, 1, $limit);
$output .= $post_id;
return $output;
}
echo generate_random_output($post_type, $post_id);
?>
Bookmarks