How can i reverse $str= "hello\n" to "olleh\n" without using any extra memory variable?
I looked up for prebuilt functions but they all use memory, also, i think string is immutable so basically can this be done without any tweak or creating a new string is the only option?
I don't think anything is immutable in PHP.
So
$str = strrev($str);
may be of some use.
Fear the micro-optimization as it will take all your time, for no real result ! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With