Trying to insert an array into an XML feed submission request to Amazon API


I am developing a script that syncs my stock quantities across Amazon, Ebay, and my website. I have now stumbled at the finishing line. I am trying to update my Amazon stock quantities using the SubmitFeedSample.php as provided by Amazon. I can update a single SKU without issue, however I need to know how to update multiple SKU quantities by passing in an array into the request.

I tried the following which did not give me any errors but has not succeeded in updating the quantities:

    $testArray = array();
	$testArray[0][0] = 'P768';
	$testArray[0][1] = 1;
	$testArray[1][0] = 'ULP40';
	$testArray[1][1] = 3;

	$toStr = '';
	for($i = 0, $j = 1; $i < sizeof($testArray); $i++, $j++) {

	    $toStr .= '&lt;Message&gt;' . '&lt;MessageID&gt;' . $j . '&lt;/MessageID&gt;' . '&lt;OperationType&gtUpdate&lt;/OperationType&gt' . '&lt;Inventory&gt;' . '&lt;SKU&gt;' . $testArray[$i][0] . '&lt;/SKU&gt;' . '&lt;Quantity&gt;' . $testArray[$i][1] . '&lt;/Quantity&gt;' . '&lt;/Inventory&gt;' . '&lt;/Message&gt;';

	$feed ='<?xml version="1.0" encoding="UTF-8"?>
	<AmazonEnvelope xsi:noNamespaceSchemaLocation="amzn-envelope.xsd" xmlns:xsi="">
	    <MessageType>Inventory</MessageType>' . $toStr . 

I am a novice programmer and I’m quite proud, and very surprised, that I’ve managed to get this far. However; I feel like there should be an easy solution for this?