- array_slice: documentation ( source)
- var_export: documentation ( source)
- array_keys: documentation ( source)
<?php
$rotor = ["A" => "R", "B" => "D", "C" => "O", "D" => "B"];
$from = "C";
foreach (array_keys($rotor) as $index => $key) {
if ($key === $from) {
$rotor = array_slice($rotor, $index, null, true) + $rotor;
break;
}
}
var_export($rotor);