PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php function reverseWordsInSentence($sentence) { $words = explode(' ', $sentence); $reversedWords = array_map(function($word) { return mb_strrev($word, 'UTF-8'); }, $words); return implode(' ', $reversedWords); } function mb_strrev($string, $encoding = 'UTF-8') { $length = mb_strlen($string, $encoding); $reversed = ''; while ($length-- > 0) { $reversed .= mb_substr($string, $length, 1, $encoding); } return $reversed; } $inputSentence = "Куда идём мы с Пятачком - Большой-большой секрет!"; $outputSentence = reverseWordsInSentence($inputSentence); echo $outputSentence;
Show:  
Copy Clear