3v4l.org

run code in 300+ PHP versions simultaneously
<?php $word="developer"; $shuffled_consonants=str_shuffle(str_replace(['a','e','i','o','u'],'',$word)); // generate shuffled string of consonants // reinsert shuffled consonants at original consonant positions echo preg_replace_callback( '~[^aeiou]~', // match each consonant at original position function($m)use($shuffled_consonants){ // pass in the shuffled string static $offset=0; // init the offset counter return $shuffled_consonants[$offset++]; // insert new consonant at original position using post-incrementation }, $word);

preferences:
23.58 ms | 406 KiB | 5 Q