<?php $string="developer"; $consonants=[]; for($offset=0, $length=strlen($string); $offset<$length; ++$offset){ // iterate each letter of the string if(strpos('aeiou',$string[$offset])===false){ // isolate the consonants $consonants[]=$string[$offset]; // store the consonant $offsets[]=$offset; // store the offset (aka indexed position of the consonant in the string) } } shuffle($consonants); // shuffle the array of stored consonants foreach($consonants as $index=>$consonant){ // iterate only the stored consonants $string[$offsets[$index]]=$consonant; // reassign the consonants in their new positions } echo $string;
You have javascript disabled. You will not be able to edit any code.