lundi 31 mai 2021

Capitalize random letters of a string in PHP

I want to capitalize random letters in a string and echo the complete sentence from hello69.world to HeLlO69.WoRlD. Each time the functions run, it should capitalize random letters and exclude special characters and digits. I've tried this so far but it only selects the first 5 characters in string every time and outputs only Capitalized letters. How to fix this?

<?php
 $string = "hellohg.09ui8vkosjbdh";

    $selchr = substr($string,0, 5);
    $caps = strtoupper($selchr);
    echo substr_replace($string, $caps,0);
?>



Aucun commentaire:

Enregistrer un commentaire