php Move the first letter of the words in a valid sentence and use them to replace the first letter of the following word. The first letter of the last word will replace the first letter of the first word in php
i need this answer :- iorem Lpsum Is iimply summy dext tf ohe trinting pnd aypesetting tndustry but i getting this answer:- Lpsum Is iimply summy dext tf ohe trinting pnd aypesetting tndustry i
function myFunction($str,$sString){
$str = str_split($str);
$sString = str_split($sString);
$sString[0] = $str[0];
return implode('',$sString);
}
$array = explode(" ", "Lorem Ipsum is simply dummy text of the printing and typesetting industry");
$array_out = [];
foreach($array as $key => $lijst){
if (strlen($lijst) > 1)
$array_out[] = myFunction($lijst,$array[$key+1]);
else
$array_out[] = $lijst;
}
echo implode(" ", $array_out);