Removal of Node Reference, Drupal 6 Ok, trying to process a script, both PHP and JavaScript, where I am moving a particular content type NODE from one reference to another. This is the structure:

I have a PROJECT
Inside each PROJECT are PAGES
Inside each PAGE are CALLOUTS
and Inside each CALLOUT are PRODUCTS.

What I want to do is take a PRODUCT from one CALLOUT to another CALLOUT. I am able to merge these, but now what I want to do is delete the first instance. An example:

I have PRODUCT AAG-794200 that is on PAGE 6 CALLOUT A. I am merging that PRODUCT with PAGE 6 CALLOUT B.

I can get the product to merge, but now I need to remove it from CALLOUT A. Here is my code:

$merge = explode(',', $merge); //Merge SKUs
$mpages = explode(',', $mpages); //Merge Pages
$mcallouts = explode(',', $mcallouts); //Merge Callouts
$mcallout_nid = explode(',', $mcallout_nid);  //Merge Current callout

$length = count($merge);
$e = 0;
while ($e &lt; $length) {
    //Where is the SKU going to?
    $to_callout_letter = strtoupper($mcallouts[$e]);
    $to_page_num = $mpages[$e];
    $sku = $merge[$e];
    $from_callout = $mcallout_nid[$e];

    //Where is the SKU coming from?     
    $other_callout = node_load($from_callout);

    //Need page ID of current callout for project purposes
    $page_nid = $other_callout-&gt;field_page[0]['nid'];
    $page = node_load($page_nid);
    //Need the project NID
    $project_nid = $page-&gt;field_project[0]['nid'];

    //We need to get the NID of the page we are going to
    $page_nid = db_query('SELECT * FROM content_type_page WHERE field_page_order_value = "%d" and field_project_nid = "%d" ORDER BY vid DESC LIMIT 1', $to_page_num, $project_nid);

    $page_nid_res = db_fetch_array($page_nid);
    $to_page_nid = $page_nid_res['nid'];

    //We need to get the NID of the callout here
    $co_nid = db_query('SELECT * FROM content_type_callout WHERE field_identifier_value = "%s" and field_page_nid = "%d"', $to_callout_letter, $to_page_nid);
    $co_nid_res = db_fetch_array($co_nid);
    $to_callout_letter_nid = $co_nid_res['nid'];


    $callout = node_load($to_callout_letter_nid);
    $long = count($other_callout-&gt;field_skus);
    $deletecallout = array();
    foreach($other_callout-&gt;field_skus as $skus) {
        $s = 0;
        while ($s &lt; $long) {
            if($skus['nid'] == $sku) {
                $callout-&gt;field_skus[] = $skus;
                $s++;
            }
            else {
                $deletecallout[] = $skus;
                $s++;
            }
        }
    }


    foreach($other_callout-&gt;field_images as $old_image) {
        $callout-&gt;field_images[] = $old_image;
    }
    foreach($other_callout-&gt;field_line_art as $old_image) {
        $callout-&gt;field_line_art[] = $old_image;
    }
    foreach($other_callout-&gt;field_swatches as $old_image) {
        $callout-&gt;field_swatches[] = $old_image;
    }

    $callout-&gt;field_copy_text[0]['value'] .= $other_callout-&gt;field_copy_text[0]['value'];
    $callout-&gt;field_notes[0]['value'] .= $other_callout-&gt;field_notes[0]['value'];
    $callout-&gt;field_image_notes[0]['value'] .= $other_callout-&gt;field_image_notes[0]['value'];
    $callout-&gt;field_status[0]['value'] = 'In Process';
    node_save($callout);


This causes the PRODUCTS to MERGE, but not delete the original.

Thanks for any help. I know it's something simple, and it will be a palm-to-face moment.
So the answer to this was easier than I thought.  I loaded the $other_callout node, and then unset the $key, utilizing the following code:

foreach($other_callout-&gt;field_skus as $key=&gt;$value) {
if($value['nid'] == $sku) {
        $sku_rec = $value;
        $sku_rec_key = $key;
    continue;
    }
}

unset($other_callout-&gt;field_skus[$sku_rec_key]);

node_save($other_callout);


Thanks for the help guys, I appreciate it.

Drupal on.