Jump to content

[SOLVED] A converting a string backwards?


Tonic-_-

Recommended Posts

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

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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.