Educated guess: (The key was to merge the arrays by using `array_merge()`) // Put all values in an array(). $AllItems = array_merge($FruitsCategory, $DrinksCategory, $DrinksCategory); // use array_merge foreach ($AllItems as $Item) { $article->field_article_all_items[] = ['target_id' => $Item]; } $article->save(); Also it can be used within the node creation: // Put all values in an array(). $AllItems = array_merge($FruitsCategory,$VegetablesCategory,$DrinksCategory); // Create a new "Article" node. $article = \Drupal\node\Entity\Node::create([ 'type' => 'article', 'title' => Test, 'langcode' => 'en', 'uid' => '1', 'status' => '1', 'created' => $current_time, 'field_article_all_items' => $AllItems, // use array_merge ]); // Save the created node. $article->save();