Views Bulk Operations execute php loop over reference values I am trying to finalize migration from d6 content profile to d7. I'd like to execute an arbirary php script using VBO to set a multi value entity reference field(users) based on the authors of a multi value node reference(bio content type) field.

I am looking for proper syntax for looping through each node reference item and populating the entity(user) reference with the uid from that node.

Final working solution:

$containing_node = node_load($entity-&gt;nid); //$nid is what node if you get from VBO
$w_containing_node = entity_metadata_wrapper('node', $containing_node);
$references = field_get_items('node', $containing_node, 'field_res_mem');
   foreach($references as $index =&gt; $value) {
     $my_index = 0;
     $reference_nid = $value['nid'];
     $rnode = node_load($reference_nid);
    $ruid = $rnode-&gt;uid;
    $w_containing_node-&gt;field_res_memuser[] = $ruid;
  }
$w_containing_node-&gt;save();
For any field that has multiple values you can use field_get_items() to retrieve all values. For your specific case with the entity reference field, you'll need to retrieve the target_id property from each field item.

  $node = node_load($nid); //$nid is the node id you get from VBO
  $references = field_get_items('node', $node, 'field_MY_REFERENCE_FIELD'); 
  foreach($references as $index =&gt; $value) {
    $reference_nid = $value['target_id'];
    //@TODO: use $reference_nid to retrieve anything about referenced node
  }