function modifyString($str) {
// Split the input string into an array of words
$words = explode(" ", $str);
// Rearrange the words in the array
$newWords = array();
for ($i = count($words) - 1; $i >= 0; $i--) {
$newWords[] = $words[$i];
}
// Join the words in the array to form the modified string
$newStr = implode(" ", $newWords);
return $newStr;
}
// Example usage
$inputStr = "My Name is Ashok Kumar";
$outputStr = modifyString($inputStr);
echo $outputStr; // Output: "Kumar Ashok is Name My"