Associating related entries to a new entry when using the API This may just be a 5PM Friday issue, but I'm scratching my head over here. I'm trying to associate a string of related entry id's represented by a variable with a new entry via the API. When I pass the variable, only the first one gets inserted into the DB. If I use the string they all get inserted. Here's the insert code:

 $article_countries = "1021,1047,1076,1123"; 

 $entry-&gt;getContent()-&gt;setAttributes(array(
   'article_countries' =&gt; array(
     $articleCountries
    )
 ));


Why is the string working where the variable isn't?
I dont think you can build arrays in PHP that way and you end up passing array(0 =&gt; '1021,1047,1076,1123') to the param.

Not shure if passing the string is supported:

'article_countries' =&gt; $article_countries


If not you could build the array like so:

'article_countries' =&gt; array_map('trim', explode(',', $article_countries))