title: How to display array data from MySql in laravel
body: <p>So I a Manifest where you can add multiple customers, produce etc and it saves in the DB as an array  </p>
  
  <p><a href="https://i.stack.imgur.com/O7fts.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O7fts.png" alt="enter image description here"></a></p>
  
  <p>Now I'm making a page where you can view all the manifest info I want it to look something like this </p>
  
  <p><a href="https://i.stack.imgur.com/MeKNK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MeKNK.png" alt="enter image description here"></a></p>
  
  <p>if I try to do something like this <code>{{ $manifest-&gt;customer_name }}</code> i get a error <code>htmlspecialchars() expects parameter 1 to be string, array given</code> because it's an array I'm only having trouble with displaying the array data </p>
  
  <p>Controller Code to get the correct manifest</p>
  
  <pre><code>public function view($id) {
  
      $manifests = Manifest::where('id', $id)-&gt;where('user_id', Auth::user()-&gt;id)-&gt;firstOrFail();
  
      return view('users.manifest.view', compact('manifests'));
  }
  </code></pre>
  
  <p>view - usually I would just put <code>{{ $manifets-&gt;customer_name }}</code> but i can't because it an array</p>
  
  <pre><code>&lt;table class="table table-striped"&gt;
                          &lt;thead&gt;
                              &lt;tr&gt;
                                  &lt;th width="15%"&gt;Customer&lt;/th&gt;
                                  &lt;th width="15%"&gt;Produce&lt;/th&gt;
                                  &lt;th width="15%"&gt;Task&lt;/th&gt;
                                  &lt;th width="15%"&gt;Units&lt;/th&gt;
                              &lt;/tr&gt;
                          &lt;/thead&gt;
                          &lt;tbody&gt;
                              &lt;tr&gt;
                                  &lt;td&gt;
                                      &lt;input type="text" class="form-control" value="{{ $manifests-&gt;customer_name }}" /&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/tbody&gt;
                      &lt;/table&gt;
  </code></pre>
  
  <p>print_r</p>
  
  <pre><code> App\Manifest Object
  (
      [table:protected] =&gt; manifest
      [fillable:protected] =&gt; Array
          (
              [0] =&gt; user_id
              [1] =&gt; date
              [2] =&gt; driver_name
              [3] =&gt; truck_number
              [4] =&gt; run_number
              [5] =&gt; customer_name
              [6] =&gt; produce
              [7] =&gt; task
              [8] =&gt; units
          )
  
      [casts:protected] =&gt; Array
          (
              [customer_name] =&gt; array
              [produce] =&gt; array
              [task] =&gt; array
              [units] =&gt; array
          )
  
      [connection:protected] =&gt; mysql
      [primaryKey:protected] =&gt; id
      [keyType:protected] =&gt; int
      [incrementing] =&gt; 1
      [with:protected] =&gt; Array
          (
          )
  
      [withCount:protected] =&gt; Array
          (
          )
  
      [perPage:protected] =&gt; 15
      [exists] =&gt; 1
      [wasRecentlyCreated] =&gt; 
      [attributes:protected] =&gt; Array
          (
              [id] =&gt; 8
              [user_id] =&gt; 1
              [date] =&gt; 2017-11-02
              [driver_name] =&gt; Harry Oberlander
              [truck_number] =&gt; 7989
              [run_number] =&gt; 8
              [customer_name] =&gt; ["evergreen","Surplus"]
              [produce] =&gt; ["Apples","Meat"]
              [task] =&gt; ["Pick Up","Delivery"]
              [units] =&gt; ["3 skids","1"]
              [created_at] =&gt; 2017-11-02 04:49:49
              [updated_at] =&gt; 2017-11-02 04:49:49
          )
  
      [original:protected] =&gt; Array
          (
              [id] =&gt; 8
              [user_id] =&gt; 1
              [date] =&gt; 2017-11-02
              [driver_name] =&gt; Harry Oberlander
              [truck_number] =&gt; 7989
              [run_number] =&gt; 8
              [customer_name] =&gt; ["evergreen","Surplus"]
              [produce] =&gt; ["Apples","Meat"]
              [task] =&gt; ["Pick Up","Delivery"]
              [units] =&gt; ["3 skids","1"]
              [created_at] =&gt; 2017-11-02 04:49:49
              [updated_at] =&gt; 2017-11-02 04:49:49
          )
  
      [dates:protected] =&gt; Array
          (
          )
  
      [dateFormat:protected] =&gt; 
      [appends:protected] =&gt; Array
          (
          )
  
      [events:protected] =&gt; Array
          (
          )
  
      [observables:protected] =&gt; Array
          (
          )
  
      [relations:protected] =&gt; Array
          (
          )
  
      [touches:protected] =&gt; Array
          (
          )
  
      [timestamps] =&gt; 1
      [hidden:protected] =&gt; Array
          (
          )
  
      [visible:protected] =&gt; Array
          (
          )
  
      [guarded:protected] =&gt; Array
          (
              [0] =&gt; *
          )
  
  )
  </code></pre>
  
  <p>here is the updated code</p>
  
  <pre><code>    @foreach($manifests as $manifest)
          &lt;tr&gt;
             &lt;td&gt;
                &lt;input type="text" class="form-control" value="{{ $manifest['customer_name'] }}" /&gt;
             &lt;/td&gt;
             &lt;td&gt;
               &lt;input type="text" class="form-control" value="{{ $manifest['produce'] }}" /&gt;
             &lt;/td&gt;
             &lt;td&gt;
               &lt;input type="text" class="form-control" value="{{ $manifest['task'] }}" /&gt;
             &lt;/td&gt;
          &lt;/tr&gt;
    @endforeach
  </code></pre>