PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php function reverseWordsInSentence($sentence) { return implode(' ', array_map(function($word) { return preg_replace('/\W/ui','',$word) != '' ? join(array_reverse(preg_split('//u', preg_replace('/\W/ui','',$word), -1, PREG_SPLIT_NO_EMPTY))) . preg_replace('/\pL/ui','',$word) : $word; }, explode(' ', $sentence))); } $inputSentence = "Куда идём мы с Пятачком - Большой-большой секрет!"; $outputSentence = reverseWordsInSentence($inputSentence); echo $outputSentence;
Show:  
Copy Clear