Answers.Body: <p>A table field contains a simple array, you can serialize and unserialize it as it is. So there is no custom action required by your side.
  Just use it in PHP like every other textual field </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-04T19:07:21.243Z
Answers.LastActivityDate: 2018-09-04T19:07:21.243Z
Answers.UserDisplayName: Robin Schambach
Body: <p>How can I output the rows and values of a table field using the element api plugin?</p>
  
  <p>Where I have entries I do</p>
  
  <pre><code>...
  $industries = [];
  foreach ($entry-&gt;industries-&gt;all() as $industry) {
    $industries[] = $industry-&gt;title;                    
  }
  ...
  return [
      'industries' =&gt; $industries
  ];
  </code></pre>
  
  <p>but <code>-&gt;all()</code> doesn't work in the scenario of a table.</p>
  
Tags: <plugin-elementapi><table-field><element>
Title: Loop over table field in Element API plugin
ThreadText: # Loop over table field in Element API plugin
  
  (Asked by: username_0 on 2018-09-04)
  
  How can I output the rows and values of a table field using the element api plugin?
  
  Where I have entries I do
  
  ```
  ...
  $industries = [];
  foreach ($entry->industries->all() as $industry) {
    $industries[] = $industry->title;                    
  }
  ...
  return [
      'industries' => $industries
  ];
  
  ```
  
  but `->all()` doesn't work in the scenario of a table.
  
  **Tags:** plugin-elementapi, table-field, element
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-09-04. Score: 1
  
  A table field contains a simple array, you can serialize and unserialize it as it is. So there is no custom action required by your side.
  Just use it in PHP like every other textual field
  
  
  ---
  
  