How to make a checkbox display an array Laravel php?

I have multiple checkboxes, I want to display an array of data when multiple checkboxes are clicked, but only one value is displayed, how to display an array ?What is the problem?

   @foreach($langs as $key => $lang)
                     <input type="checkbox" name="foo[]"  value="{{$key}}"> 
                     <label>{{ $lang }}</label>, 
   @endforeach

To controller

public function Method(Request $request)
 {
    foreach((array)$request->input('foo') as $value){
    $file = 'la.txt';
    file_put_contents($file,$value );
    }

     return redirect()->route('profile');
     
 }