Tonic-_- Posted July 15, 2009 Share Posted July 15, 2009 Well I want to sort of reverse a string without actually reversing it. I want to show it backwards... Example: High Result: ghHi or something like that, i'm not looking for the strrev function because it does the opposite of what I wanted to do... (noob..) Like I want to reverse it backwards in bytes High Bytes: Hi, gh Link to comment https://forums.phpfreaks.com/topic/166006-solved-a-converting-a-string-backwards/ Share on other sites More sharing options...
joel24 Posted July 15, 2009 Share Posted July 15, 2009 you can split the string up into an array then reverse each element of the array then implode back into a string... $string = "this is a test string!"; $array = str_split($string, 2); foreach ($array as $key => $value) { $array[$key] = strrev($value); } //you can leave as an array or implode back into a string $string = implode($array); Link to comment https://forums.phpfreaks.com/topic/166006-solved-a-converting-a-string-backwards/#findComment-875549 Share on other sites More sharing options...
Tonic-_- Posted July 15, 2009 Author Share Posted July 15, 2009 That's kind of what I was thinking I was going to have to do so i'll give it a try and reply back on results. EDIT: Thanks, got it to work with the rest of the code, works perfect. Link to comment https://forums.phpfreaks.com/topic/166006-solved-a-converting-a-string-backwards/#findComment-875553 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.