Sample Call

<?php
// SOAP_CLIENT_BASEDIR - folder that contains the PHP Toolkit and your WSDL
// $USERNAME - variable that contains your Salesforce.com username (must be in the form of an email)
// $PASSWORD - variable that contains your Salesforce.ocm password

define("SOAP_CLIENT_BASEDIR", "../../soapclient");
require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
require_once ('../../misc/globalconstants.php');

try {
  $mySforceConnection = new SforceEnterpriseClient();
  $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
  $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);

  $sObject = new SObject();
  $sObject->type = 'Contact';
  $fields = array (
    'LastName'=>'Tran',
    'BirthDate'=> '1927-01-25',
    'Phone' => '510-555-5555',
  );
  $sObject->fields = $fields;

  $sObject2 = new SObject();
  $sObject2->type = 'Contact';
  $fields['LastName'] = 'Smith';
  $fields['FirstName'] = 'Nick';
  $sObject2->fields = $fields;


  $sObject3 = new SObject();
  $sObject3->type = 'Contact';
  $fields['Phone'] = '555-555-5555';
  $sObject3->fields = $fields;

  echo "Create 3 contacts.\n";
  
  $createResponse = $mySforceConnection->create(array($sObject, $sObject2, $sObject3));
  
  print_r($createResponse);
  
  // Merge $sObject2 into $sObject
  $mergeRequest = new stdclass();
  $sObject->Id = $createResponse[0]->id;
  $mergeRequest->masterRecord = $sObject;
  $mergeRequest->comments = 'My merge comments';
  $mergeRequest->recordToMergeIds = array($createResponse[1]->id, $createResponse[2]->id);

  echo "Merge second and third contacts into the first contact.\n";
  
  $mergeResponse = $mySforceConnection->merge($mergeRequest);

  print_r($mergeResponse);
} catch (Exception $ex) {
  echo $mySforceConnection->getLastRequest();
  print_r($ex);
}
?>

Sample Output

Create 3 contacts.
Array
(
    [0] => stdClass Object
        (
            [id] => 0035000000Udh1mAAB
            [success] => 1
        )

    [1] => stdClass Object
        (
            [id] => 0035000000Udh1nAAB
            [success] => 1
        )

    [2] => stdClass Object
        (
            [id] => 0035000000Udh1oAAB
            [success] => 1
        )

)
Merge second and third contacts into the first contact.
stdClass Object
(
    [id] => 0035000000Udh1mAAB
    [mergedRecordIds] => Array
        (
            [0] => 0035000000Udh1nAAB
            [1] => 0035000000Udh1oAAB
        )

    [success] => 1
)