Reverse a String
PHP
Easy
5 views
Problem Description
Print the reverse of the given string.
Input Format
One line string s.
Output Format
One line reversed.
Official Solution
<?php
$inputText=rtrim(stream_get_contents(STDIN));
if($inputText==='') exit;
$out='';
for($i=strlen($inputText)-1;$i>=0;$i--) $out.=$inputText[$i];
echo $out;
?>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!