addfieldtofilter in magento2 behaving weirdly

0

addfieldtofilter in magento2 behaving weirdly

I have code

   foreach($userDetails as $singleUserDetails) {               
            $userid=$singleUserDetails['user_id'];
            var_dump($userid);//everytime values changes 1,2,3
            $users = $this->userCollection ->addFieldToFilter('user_id',$userid); 
            var_dump($users->getData());// output: 
                                array('id'=>1,'user_id'=>1,'user_name'=>'a'); 
                                array('id'=>1,'user_id'=>1,'user_name'=>'a'); 
                                array('id'=>1,'user_id'=>1,'user_name'=>'a');         
            }

same code If I write with passing value then it gives correct data

    foreach($userDetails as $singleUserDetails) {               
            $userid=$singleUserDetails['user_id'];
            var_dump($userid);//everytime values changes 1,2,3
            $users = $this->userCollection->addFieldToFilter('user_id',3); 
            var_dump($users->getData());// output: array('id'=>3,'user_id'=>3,'user_name'=>'c');          
            }