<?php
$arrays = [[0, 3, 10, 5, 6, 9, 2, 7, 1, 4, 8, 11], [0, 1, 2, 3], [0, 5, 2, 4, 3, 1], [0, 1, 3, 2]];
$deletes = [3, 5];
var_export(
array_map(
function($array) use ($deletes) {
$result = [];
foreach (array_diff($array, $deletes) as $value) {
$result[] = array_reduce(
$deletes,
function ($carry, $item) use ($value) {
return $carry - ($value > $item);
},
$value
);
}
return $result;
},
$arrays
)
);
- Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
- array (
0 =>
array (
0 => 0,
1 => 8,
2 => 4,
3 => 7,
4 => 2,
5 => 5,
6 => 1,
7 => 3,
8 => 6,
9 => 9,
),
1 =>
array (
0 => 0,
1 => 1,
2 => 2,
),
2 =>
array (
0 => 0,
1 => 2,
2 => 3,
3 => 1,
),
3 =>
array (
0 => 0,
1 => 1,
2 => 2,
),
)
preferences:
121.09 ms | 408 KiB | 5 Q