How to add a value to an object's array dynamically?
<p>I don't see the wood for the trees, please point me into the right direction.</p>

<p>I've got a mysql query and retrieve the rows as objects. This works fine.
Now, I want to populate an object's array with the values from the database.
This object ($myobject) has several arrays (i.e. $myobject->field_1). These arrays contain (multiple) values for a certain field in various languages, hence it could be sth. like $myobject->field_1['en'][0] = 'value'. Here's what I tried to do:</p>

<pre><code>$query = 'SELECT t.id, t.lang, t.val FROM table t';
$result = db_query($query); // custom db layer function
foreach ($result AS $row) {
    $fieldname = 'field_'.$row-&gt;id;
    $myobject-&gt;$fieldname[$row-&gt;lang][] = $row-&gt;val;
}
</code></pre>

<p>The last line is not working. Since I do not know, how many values are already stored for a language, I just want to add ([]) a value to the end of the array.</p>

<p>Which neat trick am I missing?</p>
