PHP filter array



Hello community

I need little bit of advice on how do this. I have an PHP array of strings. The strings are supposed to represent PIN codes which are of 6 digits like:

560095

Having a space after 3 digits is also considered valid as 560 095

All array elements are not valid. I want help to do this filtering to get a new array of all valid PIN codes.

I searched and looks like I may have to use regular expression. Is that correct?