我在 PHP 中有一个数组,我在从这个数组中删除一些元素时遇到了问题。它看起来像这样:
Array
(
[0] => 2x 633130A
[1] => 2x 525130B
[2] => 2x 591130B
[3] => 2x 963130B
[4] => 2x 813130B (20mm)
[5] => 2x 813130B
[6] => 2x 313130B (12mm)
[7] => 2x 313130B
[8] => 4x 413130B
[9] => 2x 633130B
[12] => 2x 381130A (23mm)
[13] => 2x 381130A
)
现在我想删除没有mm参数的重复元素,如下所示:
FROM =====> TO
Array Array
( (
[0] => 2x 633130A [0] => 2x 633130A
[1] => 2x 525130B [1] => 2x 525130B
[2] => 2x 591130B [2] => 2x 591130B
[3] => 2x 963130B [3] => 2x 963130B
[4] => 2x 813130B (20mm) [4] => 2x 813130B (20mm)
[5] => 2x 813130B <= REMOVE [5] => 2x 313130B (12mm)
[6] => 2x 313130B (12mm) [6] => 4x 413130B
[7] => 2x 313130B <= REMOVE [7] => 2x 633130B
[8] => 4x 413130B [8] => 2x 381130A (23mm)
[9] => 2x 633130B )
[12] => 2x 381130A (23mm)
[13] => 2x 381130A <= REMOVE
)
我试过array_unique在这种情况下不起作用,因为元素不完全相同。谁能帮我删除那些重复的元素?