如何从字符串数组中删除错误的符号和错误的长度字符串?

I have such array:

$array = array('abC12', 'bC44', 'Am286c$', 'cC092', 'cC09288');

With using rexexp it is necessary to, at first, delete symbols (replace by ''), that are not in [A-Ca-c0-9]. At second, it is necessary to delete from array variables that not match such condition: string length not equal to 5 (values 'bC44' and 'cC09288').

So, as result array must contain:

$array = array('abC12', 'A286c', 'cC092');

Thanks you for any help!

Vladimir.

$result = array();
foreach ($array as $val) {
    $val = preg_replace('/[^a-c0-9]/i', '', $val); // Remove symbols
    if (strlen($val) == 5) { // Check string length
        $result[] = $val;
    }
}

How about:

$array = array('abC12', 'bC44', 'Am286c$', 'cC092', 'cC09288');
$array = array_filter(preg_replace('/[^a-c0-9]/i', '',$array),function ($var) {return strlen($var) == 5;});
print_r($array);

output:

Array
(
    [0] => abC12
    [2] => A286c
    [3] => cC092
)

preg_replace acts also on array.
Documentation preg_replace, array_filter