Reverse a string with php

后端 未结 16 1124
南笙
南笙 2020-12-03 23:42

I am trying to find a way to reverse a string, I\'ve seen alternatives but i wanted to to it this way thinking outside the box and not using anyone else\'s code as an altern

16条回答
  •  醉酒成梦
    2020-12-04 00:23

    You're trying much too hard, always consult the manual and/or a search engine to check if there are native functions to do what you want before you end up "reinventing the wheel":

    strrev — Reverse a string

    http://php.net/manual/en/function.strrev.php

    $string = "This is a reversed string";
    echo strrev($string);
    // Output: gnirts desrever a si sihT
    

提交回复
热议问题