Hallo Lichtundschatten,
$teile = explode('Platzhalter', $text);
$text = '';
$cnt = count($teile);
for ($i = 0; $i < $cnt; $i++) {
if ($i < $cnt - 1) {
if (0 == count($zufallersetzung))
throw new Exception('zu wenig Zufallswerte');
$key = array_rand($zufallersetzung);
$text .= $teile[$i] . $zufallersetzung[$key];
unset($zufallersetzung[$key]);
}
else {
$text .= $teile[$i];
}
}
echo $text;
Was eleganteres fällt mir so schnell nicht ein. Da muss noch darauf geachtet werden, dass genug Zufallswerte zur Verfügung stehen bzw. ein Prüfmechanismus einbauen, sonst wird Exception geworfen.
Gruß Alexander.