Reversing a String by Word or Character

You want to reverse the words or the characters in a string. Solution Use strrev( ) to reverse by character: print strrev(‘This is not a palindrome.’); .emordnilap a ton si sihT To reverse by words, explode the string by word boundary, reverse the words, then rejoin: $s = “Once upon a time there was a turtle.”; // break the string…

Continue reading