<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>

CC BY-SA 4.0
2018-09-04T19:07:21.243Z
2018-09-04T19:07:21.243Z
Robin Schambach
<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>

<plugin-elementapi><table-field><element>
Loop over table field in Element API plugin
# 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


---

