<?php
$_pr = '123456';
$_pu = 'abcdef';
$_puArr = [];
$newArr = [];
$code = '';
for ($i = 0; $i < strlen($_pu); $i++) {
$_puArr[] = ['id' => $_pu[$i], 'text' => $_pr[$i]];
}
function sortByKey($key, $array, $callback) {
usort($array, function($a, $b) use ($key, $callback) {
return $callback($a[$key], $b[$key]);
});
return $array;
}
$newArr = sortByKey('id', $_puArr, function($a, $b) {
return $a - $b;
});
for ($i = 0; $i < count($newArr); $i++) {
$code .= $newArr[$i]['text'];
}
echo $code;
?>