This code is quick and dirty, definitely not the type I normally code, but I am on my way out the door and thought I would drop this before I left. May not be your solution, but it might point you in the right direction.
Because our array has $dev_contact_fname twice, this comes in handy for testing. When ran as above, the output is 2. If you change the first name to "" and the last name to "Joe", then the output is 1. Code has been tested.