<?php $data = [ 'Light Blue1', 'Blue2', 'Blue1', 'Black3', 'Black12', 'Black2' ]; $result = []; foreach ($data as $value) { sscanf($value, '%[^0-9]%d', $color, $number); if (!isset($result[$color]) || $result[$color]['number'] < $number) { $result[$color] = ['value' => $value, 'number' => $number]; } } var_export(array_column($result, 'value'));
You have javascript disabled. You will not be able to edit any code.