Say I have a dataset, each element has an associated “score”.
eg:
Banana – 5
Apple – 3
Pear – 2
I want to invert the scale so that :
All 5’s become 1’s
All 4’s become 2’s
All 3’s become 3’s
All 2’s become 4’s
All 1’s become 5’s
So I’d end up with
Banana – 1
Apple – 3
Pear – 4
I’m struggling to find a graceful solution that doesn’t involve creating a map.
The formula is
$new = -$old + 6. Just use it with array_map