Programmatically entering data into a table field for an entry I now know that you can enter data into an entry's field by using $event-&gt;params['entry']-&gt;getContent()-&gt;handle 

But let's say I have a foreach loop and I want to enter each line into an entry that is a table field. So for example:

foreach ($apigrab['properties'] as $specs) {
    $event-&gt;params['entry']-&gt;getContent()-&gt;specs == ??
}


Obviously each table heading has it's own handle and I don't imagine specs.handle would work in this case, and also how would you prevent it from just overwriting the same line over and over again? Would I have to count how many first and tell it specifically where to go?

Thanks in advance.
When saving data to a Table field, here's the catch... Your field data is being condensed into JSON and stored in a single database table cell.

So ultimately, you'll want to have your Table field data arranged in an array, then use json_encode to prep it for entry into the database.

Here's an example of data for a Table field... This is a hypothetical field containing products, with a Product Name and prices for Small, Medium, and Large...

[
  {
    "col1": "Product #1",
    "col2": "5",
    "col3": "10",
    "col4": "15"
  },
  {
    "col1": "Product #2",
    "col2": "7",
    "col3": "14",
    "col4": "21"
  },
  {
    "col1": "Product #3",
    "col2": "7",
    "col3": "14",
    "col4": "21"
  }
]


An important note... The column names you established when setting up your Table field are not relevant here. Instead, each columnn will be referred to as "col1", "col2", "col3", etc.