title: Tab-delimited PHP string to array
body: <p>I am using the AmazonMwsComplete repo on GitHub to make requests to Amazon's AWS API, specifically the GetReport call. I'm getting a positive response from my requests so it all seems to be working fine, the only issue is that it appears to transform the XML response into a tab-delimited string that I can't work-out how to correctly format into a PHP array.</p>
  
  <p>Essentially, the response looks something like this:</p>
  
  <pre><code>string(52148) "sku     asin    price   quantity       Business Price Quantity Price Type        Quantity Lower Bound 1 Quantity Price 1       Quantity Lower Bound 2 Quantity Price 2 Quantity Lower Bound 3 Quantity Price 3       Quantity Lower Bound 4 Quantity Price 4 Quantity Lower Bound 5 Quantity Price 5       ProductTaxCode VatExclusivePrice        VatExclusiveBusinessPrice      VatExclusiveQuantityPrice1        VatExclusiveQuantityPrice2     VatExclusiveQuantityPrice3        VatExclusiveQuantityPrice4     VatExclusiveQuantityPrice5
  XX-XXXX-XXXX   XXXXXXXXXX     0.01   1                                                                                                                                                        
  XX-XXXX-XXX   XXXXXXXXXX     0.01    1                                                                                                                                                       
  XXX-XXX-XXX    XXXXXXXXXX     0.01   1“
  </code></pre>
  
  <p>When I convert this into an array it looks like this: </p>
  
  <pre><code>array(22702) {
    [0]=&gt;
    string(3) "sku"
    [1]=&gt;
    string(4) "asin"
    [2]=&gt;
    string(5) "price"
    [3]=&gt;
    string(8) "quantity"
    [4]=&gt;
    string(14) "Business Price"
    [5]=&gt;
    string(19) "Quantity Price Type"
    [6]=&gt;
    string(22) "Quantity Lower Bound 1"
    [7]=&gt;
    string(16) "Quantity Price 1"
    [8]=&gt;
    string(22) "Quantity Lower Bound 2"
    [9]=&gt;
    string(16) "Quantity Price 2"
    [10]=&gt;
    string(22) "Quantity Lower Bound 3"
    [11]=&gt;
    string(16) "Quantity Price 3"
    [12]=&gt;
    string(22) "Quantity Lower Bound 4"
    [13]=&gt;
    string(16) "Quantity Price 4"
    [14]=&gt;
    string(22) "Quantity Lower Bound 5"
    [15]=&gt;
    string(16) "Quantity Price 5"
    [16]=&gt;
    string(14) "ProductTaxCode"
    [17]=&gt;
    string(17) "VatExclusivePrice"
    [18]=&gt;
    string(25) "VatExclusiveBusinessPrice"
    [19]=&gt;
    string(26) "VatExclusiveQuantityPrice1"
    [20]=&gt;
    string(26) "VatExclusiveQuantityPrice2"
    [21]=&gt;
    string(26) "VatExclusiveQuantityPrice3"
    [22]=&gt;
    string(26) "VatExclusiveQuantityPrice4"
    [23]=&gt;
    string(40) "VatExclusiveQuantityPrice5
  XX-XXXX-XXXX"
    [24]=&gt;
    string(10) "XXXXXXXXX"
    [25]=&gt;
    string(5) "0.01"
    [26]=&gt;
    string(1) "1"
    [27]=&gt;
    string(0) ""
    [28]=&gt;
    string(0) ""
    [29]=&gt;
    string(0) ""
    [30]=&gt;
    string(0) ""
  }
  </code></pre>
  
  <p>There’s a few problems with this, the “VatExclusiveQuantityPrice5” heading is mixed in with the first piece of information which is the product SKU so it’s in the same element in the array.</p>
  
  <p>The tab-delimited string also uses 20 tabs as a ‘new line’ break, so I end up with 20 blank elements in the array before the next piece of information.</p>
  
  <p>I have one possible solution to this that involves converting it into a text file and importing straight into a database, but surely there must be a simple way to convert this into a PHP array, the database option seems a far more difficult way to go about handling this information.</p>