Reverse a String

Reverse a String

Easy PHP PHP Strings 40 views
Explanation Complexity

Problem Statement

Print the reverse of the given string.

Input Format

One line string s.

Output Format

One line reversed.

Example

hello
olleh

Constraints

|s|

Input / Output Format

Input Format
One line string s.
Output Format
One line reversed.
Constraints
|s|

Examples

Input:
hello
Output:
olleh

Example Solution (Public)

PHP
<?php
$inputText=rtrim(stream_get_contents(STDIN));
if($inputText==='') exit;
$out='';
for($i=strlen($inputText)-1;$i>=0;$i--) $out.=$inputText[$i];
echo $out;
?>

Official Solution Code

<?php
$inputText=rtrim(stream_get_contents(STDIN));
if($inputText==='') exit;
$out='';
for($i=strlen($inputText)-1;$i>=0;$i--) $out.=$inputText[$i];
echo $out;
?>
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.