This would look a lot cleaner:

    is_int($key) OR $key = "'".$key."'";