I tried to replace a certain word with difference generated keys
This is my code, that replace all 1
with one similar key:
function generate($qtd){
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $qtd; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
$text = "nksn 1 kn ksn1dfub fui b 1uwbq k1m;lml1nfsbfjbj susksfk b1woub js sl m;sn1fjs";
$le = 10;
echo str_replace('sn', generate($le), $text);
Help please, Thanks
Aucun commentaire:
Enregistrer un commentaire