Currently, you only fetch a single random character and use it to join the characters together - this means that the same character will be used every time.
If you want to generate a new character for each delimiter, you will need to pass the input string into your function, something like this:
function insert_random_chars($str, $alphabet = "ABCDEFGHIJKLMNOPGRSTUVWXYZ")
{
// An array to hold the result
$result = array();
// The highest character index in the string
$max = strlen($alphabet) - 1;
// Loop the characters in the input string
foreach (str_split($str, 1) as $char) {
// Add the current character and a random character to the output array
array_push($result, $char, $alphabet[mt_rand(0, $max)]);
}
// Join the output array together
return implode('', $result);
}
echo insert_random_chars("0123456789");
0L1E2G3T4F5S6E7F8I9M
Note that this code doesn't do precisely what you want, but it should give you a push in the right direction ;-)