- substr_count: documentation ( source)
- strpos: documentation ( source)
- str_repeat: documentation ( source)
- array_shift: documentation ( source)
- str_split: documentation ( source)
<?php
$str = '_10_1_18_4_9_14_ _';
$letters = str_repeat('A', substr_count($str, '_'));
$limit = 100;
for ($i = 0; $i < $limit; $i++) {
echo interpolate($str, str_split($letters)), PHP_EOL;
$letters++;
}
function interpolate($str, $letters) {
while (($pos = strpos($str, '_')) !== false) {
$str[$pos] = array_shift($letters);
}
return $str;
}