PHP Online Compiler
Example: PHP Program to Reverse a String using For loop
C
C++
C#
Java
Python
PHP
main.php
STDIN
Run
<?php // PHP Program to Reverse a String using For loop $x = "hello world"; echo "The input string is: ", $x, "\n\n"; echo "The reverse of the string is: "; for ($i = (strlen ($x) - 1); $i >= 0; $i--) { echo $x[$i]; } echo "\n"; ?>
Output
Clear
ADVERTISEMENTS