// Ex. 1: signedShiftArray (['A', 'B', 'C', 'D'], 2)        ->        ['C', 'D', 'A', 'B']
// Ex. 2: signedShiftArray (['A', 'B', 'C', 'D'], -3)        ->        ['B', 'C', 'D', 'A']
// Ex. 3: signedShiftArray (['A', 'B', 'C', 'D'], -7)        ->        ['B', 'C', 'D', 'A']
function signedShiftArray ($aItems, $aOffset)
{
    if (empty ($aItems))
        return [];
    else if (empty ($aOffset))
        return $aItems;
    else {
        $t= count ($aItems);
        $n= $aOffset % $t;
        $m= $aOffset > 0 ? $n : $t + $aOffset;
        return array_merge (array_slice ($aItems, $n), array_slice ($aItems, 0, $m));
    }
}