Javatpoint Logo
Javatpoint Logo

Reverse String

A string can be reversed either using strrev() function or simple PHP code.

For example, on reversing JAVATPOINT it will become TNIOPTAVAJ.

Logic:

  • Assign the string to a variable.
  • Calculate length of the string.
  • Declare variable to hold reverse string.
  • Run for loop.
  • Concatenate string inside for loop.
  • Display reversed string.

Reverse String using strrev() function

A reverse string program using strrev() function is shown.

Example:

Output:

PHP Reverse string 1

Reverse String Without using strrev() function

A reverse string program without using strrev() function is shown.

Example:

Output:

PHP Reverse string 2




Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA