Reverse String Function
PHP
Easy
6 views
Problem Description
Write a function reverseStr(s) and print the reversed string.
Input Format
One line string s.
Output Format
One line reversed.
Official Solution
<?php
$inputText=rtrim(stream_get_contents(STDIN));
if($inputText==='') exit;
function reverseStr($t){
$out='';
for($i=strlen($t)-1;$i>=0;$i--) $out.=$t[$i];
return $out;
}
echo reverseStr($inputText);
?>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!