Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$input = '123456789123456';
$map = [5, 8, 13, 2, 4, 11, 0, 14, 1, 7, 3, 12, 10, 6, 9];
$result = '';
foreach ($map as $offset) {
$result .= $input[$offset];
}
echo "Rearranged: $result\n---\n";
$reverted = '';
asort($map);
foreach ($map as $offset => $notUsed) {
$reverted .= $result[$offset];
}
echo "Reverted: $reverted";