Advertisement
touhid_xml

Reversing string in php

Sep 21st, 2017
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function reverseString($string){
  3.     $to_return = '';
  4.     $chars = str_split($string);
  5.     $ln = count($chars);
  6.     for($i =  $ln - 1; $i>=0; $i--){
  7.     $to_return .= $chars[$i];
  8.     }
  9.     return $to_return;
  10. }
  11.  
  12. echo reverseString("Hello World");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement