title: Need an associative array but with the same keys for NuSoap
body: <p>I need to make a repeating array for this part of xml as an array, but as you can see there is a repeating item here.</p>
  
  <pre><code>    &lt;orderItems&gt;
        &lt;OrderItemRequest&gt;
          &lt;line_id&gt;int&lt;/line_id&gt;
          &lt;product_id&gt;string&lt;/product_id&gt;
          &lt;product_variant_id&gt;string&lt;/product_variant_id&gt;
          &lt;product_desc&gt;string&lt;/product_desc&gt;
          &lt;quantity&gt;int&lt;/quantity&gt;
          &lt;variant_desc&gt;string&lt;/variant_desc&gt;
          &lt;item_total&gt;decimal&lt;/item_total&gt;
        &lt;/OrderItemRequest&gt;
        &lt;OrderItemRequest&gt;
          &lt;line_id&gt;int&lt;/line_id&gt;
          &lt;product_id&gt;string&lt;/product_id&gt;
          &lt;product_variant_id&gt;string&lt;/product_variant_id&gt;
          &lt;product_desc&gt;string&lt;/product_desc&gt;
          &lt;quantity&gt;int&lt;/quantity&gt;
          &lt;variant_desc&gt;string&lt;/variant_desc&gt;
          &lt;item_total&gt;decimal&lt;/item_total&gt;
        &lt;/OrderItemRequest&gt;
      &lt;/orderItems&gt;
  </code></pre>
  
  <p>This is what I had tried to do:</p>
  
  <pre><code>$orderItemRequest = "";
  
  foreach($requestArray as $array) {
      foreach ($array as $key =&gt; $val) {
          $orderItemRequest .= $comma."&lt;$key&gt;";
  
          foreach ($val as $key2 =&gt; $val2) {
              $orderItemRequest .= "&lt;$key2&gt;$val2&lt;/$key2&gt;";
          }
  
          $orderItemRequest .= "&lt;/$key&gt;";
      }
  }
  
  array('carrier_code' =&gt; 'UPS',
  'dob' =&gt; date("Y-m-d", strtotime($dob)),
  'creditcard_number' =&gt; $CCNumber,
  'card_type' =&gt; $CCType,
  'card_expire_date' =&gt; $CCExpireMonth."/".$CCExpireYear,
  'CV_Code' =&gt; $CCSecurity,
  'Customer_Email' =&gt; $email,
  'orderItems' =&gt; $orderItemRequest,
  'ChallengeQuestion' =&gt; '',
  'ChallengeAnswer' =&gt; '',
  'localeSetting' =&gt; '',
  'ignoreAddressValidation' =&gt; '1',
  'auth_code' =&gt; '',
  'affiliate_code' =&gt; '');
  </code></pre>
  
  <p>I've tried to insert the xml directly as the value of <code>orderItems</code> but get the error: <code>nusoap_client: got wsdl error: phpType is struct, but value is not an array: see debug output for details</code>.</p>
  
  <p>Here is the last bit of the debug info:</p>
  
  <p>2013</p>
  
  <pre><code>-04-27 05:22:42.816864 wsdl: in serializeType: name=orderItems, type=http://phepartnerws/:ArrayOfOrderItemRequest, use=literal, encodingStyle=, unqualified=qualified
  value=string(845) "&lt;OrderItemRequest&gt;&lt;line_id&gt;0&lt;/line_id&gt;&lt;product_id&gt;005K&lt;/product_id&gt;&lt;product_variant_id&gt;005K&lt;/product_variant_id&gt;&lt;product_desc&gt;TANTRIC AURA MASSAGER&lt;/product_desc&gt;&lt;variant_desc&gt;TANTRIC AURA MASSAGER&lt;/variant_desc&gt;&lt;quantity&gt;1&lt;/quantity&gt;&lt;item_total&gt;24.98&lt;/item_total&gt;&lt;/OrderItemRequest&gt;&lt;OrderItemRequest&gt;&lt;line_id&gt;1&lt;/line_id&gt;&lt;product_id&gt;754&lt;/product_id&gt;&lt;product_variant_id&gt;754&lt;/product_variant_id&gt;&lt;product_desc&gt;SENSUAL SUBMISSION KIT&lt;/product_desc&gt;&lt;variant_desc&gt;SENSUAL SUBMISSION KIT&lt;/variant_desc&gt;&lt;quantity&gt;2&lt;/quantity&gt;&lt;item_total&gt;31.48&lt;/item_total&gt;&lt;/OrderItemRequest&gt;&lt;OrderItemRequest&gt;&lt;line_id&gt;2&lt;/line_id&gt;&lt;product_id&gt;239&lt;/product_id&gt;&lt;product_variant_id&gt;239&lt;/product_variant_id&gt;&lt;product_desc&gt;G-SPOT VIBE AND LUBE&lt;/product_desc&gt;&lt;variant_desc&gt;G-SPOT VIBE AND LUBE&lt;/variant_desc&gt;&lt;quantity&gt;1&lt;/quantity&gt;&lt;item_total&gt;14.95&lt;/item_total&gt;&lt;/OrderItemRequest&gt;"
  2013-04-27 05:22:42.816888 wsdl: in serializeType: got a prefixed type: ArrayOfOrderItemRequest, http://phepartnerws/
  2013-04-27 05:22:42.816904 wsdl: in getTypeDef: type=ArrayOfOrderItemRequest, ns=http://phepartnerws/
  2013-04-27 05:22:42.816918 wsdl: in getTypeDef: have schema for namespace http://phepartnerws/
  2013-04-27 05:22:42.816937 nusoap_xmlschema: &lt;http://phepartnerws/&gt; in getTypeDef, found complexType ArrayOfOrderItemRequest
  2013-04-27 05:22:42.816954 wsdl: in getTypeDef: found type ArrayOfOrderItemRequest
  2013-04-27 05:22:42.816968 wsdl: in serializeType: found typeDef
  typeDef=array(6) {
    ["name"]=&gt;
    string(23) "ArrayOfOrderItemRequest"
    ["typeClass"]=&gt;
    string(11) "complexType"
    ["phpType"]=&gt;
    string(6) "struct"
    ["simpleContent"]=&gt;
    string(5) "false"
    ["compositor"]=&gt;
    string(8) "sequence"
    ["elements"]=&gt;
    array(1) {
      ["OrderItemRequest"]=&gt;
      array(6) {
        ["minOccurs"]=&gt;
        string(1) "0"
        ["maxOccurs"]=&gt;
        string(9) "unbounded"
        ["name"]=&gt;
        string(16) "OrderItemRequest"
        ["nillable"]=&gt;
        string(4) "true"
        ["type"]=&gt;
        string(37) "http://phepartnerws/:OrderItemRequest"
        ["form"]=&gt;
        string(9) "qualified"
      }
    }
  }
  2013-04-27 05:22:42.817006 wsdl: in serializeType: uqType: ArrayOfOrderItemRequest, ns: http://phepartnerws/, phptype: struct, arrayType: 
  2013-04-27 05:22:42.817022 wsdl: in serializeType: phpType is struct, but value is not an array
  2013-04-27 05:22:42.817037 wsdl: in serializeType: returning: 
  2013-04-27 05:22:42.817058 wsdl: in serializeType: name=CV_Code, type=http://www.w3.org/2001/XMLSchema:string, use=literal, encodingStyle=, unqualified=qualified
  value=string(3) "123"
  2013-04-27 05:22:42.817080 wsdl: in serializeType: got a prefixed type: string, http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817095 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
  2013-04-27 05:22:42.817115 wsdl: in getTypeDef: type=string, ns=http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817131 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817146 wsdl: in serializeType: returning: &lt;CV_Code&gt;123&lt;/CV_Code&gt;
  2013-04-27 05:22:42.817166 wsdl: in serializeType: name=ChallengeQuestion, type=http://www.w3.org/2001/XMLSchema:string, use=literal, encodingStyle=, unqualified=qualified
  value=string(0) ""
  2013-04-27 05:22:42.817189 wsdl: in serializeType: got a prefixed type: string, http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817203 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
  2013-04-27 05:22:42.817222 wsdl: in getTypeDef: type=string, ns=http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817238 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817252 wsdl: in serializeType: returning: &lt;ChallengeQuestion&gt;&lt;/ChallengeQuestion&gt;
  2013-04-27 05:22:42.817273 wsdl: in serializeType: name=ChallengeAnswer, type=http://www.w3.org/2001/XMLSchema:string, use=literal, encodingStyle=, unqualified=qualified
  value=string(0) ""
  2013-04-27 05:22:42.817294 wsdl: in serializeType: got a prefixed type: string, http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817309 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
  2013-04-27 05:22:42.817328 wsdl: in getTypeDef: type=string, ns=http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817344 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817359 wsdl: in serializeType: returning: &lt;ChallengeAnswer&gt;&lt;/ChallengeAnswer&gt;
  2013-04-27 05:22:42.817382 wsdl: in serializeType: name=localeSetting, type=http://www.w3.org/2001/XMLSchema:string, use=literal, encodingStyle=, unqualified=qualified
  value=string(0) ""
  2013-04-27 05:22:42.817404 wsdl: in serializeType: got a prefixed type: string, http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817419 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
  2013-04-27 05:22:42.817438 wsdl: in getTypeDef: type=string, ns=http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817454 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817469 wsdl: in serializeType: returning: &lt;localeSetting&gt;&lt;/localeSetting&gt;
  2013-04-27 05:22:42.817492 wsdl: in serializeType: name=ignoreAddressValidation, type=http://www.w3.org/2001/XMLSchema:boolean, use=literal, encodingStyle=, unqualified=qualified
  value=string(1) "1"
  2013-04-27 05:22:42.817514 wsdl: in serializeType: got a prefixed type: boolean, http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817529 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
  2013-04-27 05:22:42.817546 wsdl: in getTypeDef: type=boolean, ns=http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817561 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817576 wsdl: in serializeType: returning: &lt;ignoreAddressValidation&gt;true&lt;/ignoreAddressValidation&gt;
  2013-04-27 05:22:42.817596 wsdl: in serializeType: name=auth_code, type=http://www.w3.org/2001/XMLSchema:string, use=literal, encodingStyle=, unqualified=qualified
  value=string(0) ""
  2013-04-27 05:22:42.817618 wsdl: in serializeType: got a prefixed type: string, http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817633 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
  2013-04-27 05:22:42.817651 wsdl: in getTypeDef: type=string, ns=http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817667 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817681 wsdl: in serializeType: returning: &lt;auth_code&gt;&lt;/auth_code&gt;
  2013-04-27 05:22:42.817702 wsdl: in serializeType: name=affiliate_code, type=http://www.w3.org/2001/XMLSchema:string, use=literal, encodingStyle=, unqualified=qualified
  value=string(0) ""
  2013-04-27 05:22:42.817723 wsdl: in serializeType: got a prefixed type: string, http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817738 wsdl: in serializeType: type namespace indicates XML Schema or SOAP Encoding type
  2013-04-27 05:22:42.817757 wsdl: in getTypeDef: type=string, ns=http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817773 wsdl: in getTypeDef: do not have schema for namespace http://www.w3.org/2001/XMLSchema
  2013-04-27 05:22:42.817787 wsdl: in serializeType: returning: &lt;affiliate_code&gt;&lt;/affiliate_code&gt;
  2013-04-27 05:22:42.817805 wsdl: in serializeType: returning: &lt;oOrderRequest&gt;&lt;RequestCredentials&gt;&lt;CallerID&gt;livereps&lt;/CallerID&gt;&lt;Timestamp&gt;2013-04-27T01:22:42-04:00&lt;/Timestamp&gt;&lt;Token&gt;1/kUrVDZmoYqbj1/PhCE4w==&lt;/Token&gt;&lt;/RequestCredentials&gt;&lt;company&gt;&lt;/company&gt;&lt;xml&gt;&lt;/xml&gt;&lt;partnerID&gt;livereps&lt;/partnerID&gt;&lt;sourceCode&gt;&lt;/sourceCode&gt;&lt;item_total&gt;102.89&lt;/item_total&gt;&lt;amount_total&gt;122.89&lt;/amount_total&gt;&lt;amount_tax&gt;6.69&lt;/amount_tax&gt;&lt;shipping_charge&gt;20.00&lt;/shipping_charge&gt;&lt;shipping_total&gt;20.00&lt;/shipping_total&gt;&lt;shipping_allowance&gt;0&lt;/shipping_allowance&gt;&lt;amount_ins&gt;0&lt;/amount_ins&gt;&lt;order_create_date&gt;2013-04-27&lt;/order_create_date&gt;&lt;amount_disc&gt;&lt;/amount_disc&gt;&lt;bfirst&gt;James&lt;/bfirst&gt;&lt;blast&gt;James&lt;/blast&gt;&lt;baddr1&gt;Jewell&lt;/baddr1&gt;&lt;baddr2&gt;&lt;/baddr2&gt;&lt;bcity&gt;Cincinnati&lt;/bcity&gt;&lt;bstate&gt;OH&lt;/bstate&gt;&lt;bcountry&gt;US&lt;/bcountry&gt;&lt;bzip&gt;45255&lt;/bzip&gt;&lt;sfirst&gt;James&lt;/sfirst&gt;&lt;slast&gt;James&lt;/slast&gt;&lt;saddr1&gt;Jewell&lt;/saddr1&gt;&lt;saddr2&gt;&lt;/saddr2&gt;&lt;scity&gt;Cincinnati&lt;/scity&gt;&lt;sstate&gt;OH&lt;/sstate&gt;&lt;scountry&gt;US&lt;/scountry&gt;&lt;szip&gt;45255&lt;/szip&gt;&lt;carrier_code&gt;UPS&lt;/carrier_code&gt;&lt;dob&gt;1970-01-01&lt;/dob&gt;&lt;creditcard_number&gt;5434651900577797&lt;/creditcard_number&gt;&lt;card_type&gt;M&lt;/card_type&gt;&lt;card_expire_date&gt;01/14&lt;/card_expire_date&gt;&lt;Customer_Email&gt;jamesnjewell@yahoo.com&lt;/Customer_Email&gt;&lt;CV_Code&gt;123&lt;/CV_Code&gt;&lt;ChallengeQuestion&gt;&lt;/ChallengeQuestion&gt;&lt;ChallengeAnswer&gt;&lt;/ChallengeAnswer&gt;&lt;localeSetting&gt;&lt;/localeSetting&gt;&lt;ignoreAddressValidation&gt;true&lt;/ignoreAddressValidation&gt;&lt;auth_code&gt;&lt;/auth_code&gt;&lt;affiliate_code&gt;&lt;/affiliate_code&gt;&lt;/oOrderRequest&gt;
  2013-04-27 05:22:42.817823 wsdl: in serializeType: returning: &lt;CreateOrder xmlns="http://phepartnerws/"&gt;&lt;oOrderRequest&gt;&lt;RequestCredentials&gt;&lt;CallerID&gt;livereps&lt;/CallerID&gt;&lt;Timestamp&gt;2013-04-27T01:22:42-04:00&lt;/Timestamp&gt;&lt;Token&gt;1/kUrVDZmoYqbj1/PhCE4w==&lt;/Token&gt;&lt;/RequestCredentials&gt;&lt;company&gt;&lt;/company&gt;&lt;xml&gt;&lt;/xml&gt;&lt;partnerID&gt;livereps&lt;/partnerID&gt;&lt;sourceCode&gt;&lt;/sourceCode&gt;&lt;item_total&gt;102.89&lt;/item_total&gt;&lt;amount_total&gt;122.89&lt;/amount_total&gt;&lt;amount_tax&gt;6.69&lt;/amount_tax&gt;&lt;shipping_charge&gt;20.00&lt;/shipping_charge&gt;&lt;shipping_total&gt;20.00&lt;/shipping_total&gt;&lt;shipping_allowance&gt;0&lt;/shipping_allowance&gt;&lt;amount_ins&gt;0&lt;/amount_ins&gt;&lt;order_create_date&gt;2013-04-27&lt;/order_create_date&gt;&lt;amount_disc&gt;&lt;/amount_disc&gt;&lt;bfirst&gt;James&lt;/bfirst&gt;&lt;blast&gt;James&lt;/blast&gt;&lt;baddr1&gt;Jewell&lt;/baddr1&gt;&lt;baddr2&gt;&lt;/baddr2&gt;&lt;bcity&gt;Cincinnati&lt;/bcity&gt;&lt;bstate&gt;OH&lt;/bstate&gt;&lt;bcountry&gt;US&lt;/bcountry&gt;&lt;bzip&gt;45255&lt;/bzip&gt;&lt;sfirst&gt;James&lt;/sfirst&gt;&lt;slast&gt;James&lt;/slast&gt;&lt;saddr1&gt;Jewell&lt;/saddr1&gt;&lt;saddr2&gt;&lt;/saddr2&gt;&lt;scity&gt;Cincinnati&lt;/scity&gt;&lt;sstate&gt;OH&lt;/sstate&gt;&lt;scountry&gt;US&lt;/scountry&gt;&lt;szip&gt;45255&lt;/szip&gt;&lt;carrier_code&gt;UPS&lt;/carrier_code&gt;&lt;dob&gt;1970-01-01&lt;/dob&gt;&lt;creditcard_number&gt;5434651900577797&lt;/creditcard_number&gt;&lt;card_type&gt;M&lt;/card_type&gt;&lt;card_expire_date&gt;01/14&lt;/card_expire_date&gt;&lt;Customer_Email&gt;jamesnjewell@yahoo.com&lt;/Customer_Email&gt;&lt;CV_Code&gt;123&lt;/CV_Code&gt;&lt;ChallengeQuestion&gt;&lt;/ChallengeQuestion&gt;&lt;ChallengeAnswer&gt;&lt;/ChallengeAnswer&gt;&lt;localeSetting&gt;&lt;/localeSetting&gt;&lt;ignoreAddressValidation&gt;true&lt;/ignoreAddressValidation&gt;&lt;auth_code&gt;&lt;/auth_code&gt;&lt;affiliate_code&gt;&lt;/affiliate_code&gt;&lt;/oOrderRequest&gt;&lt;/CreateOrder&gt;
  2013-04-27 05:22:42.817840 wsdl: serializeRPCParameters returning: &lt;CreateOrder xmlns="http://phepartnerws/"&gt;&lt;oOrderRequest&gt;&lt;RequestCredentials&gt;&lt;CallerID&gt;livereps&lt;/CallerID&gt;&lt;Timestamp&gt;2013-04-27T01:22:42-04:00&lt;/Timestamp&gt;&lt;Token&gt;1/kUrVDZmoYqbj1/PhCE4w==&lt;/Token&gt;&lt;/RequestCredentials&gt;&lt;company&gt;&lt;/company&gt;&lt;xml&gt;&lt;/xml&gt;&lt;partnerID&gt;livereps&lt;/partnerID&gt;&lt;sourceCode&gt;&lt;/sourceCode&gt;&lt;item_total&gt;102.89&lt;/item_total&gt;&lt;amount_total&gt;122.89&lt;/amount_total&gt;&lt;amount_tax&gt;6.69&lt;/amount_tax&gt;&lt;shipping_charge&gt;20.00&lt;/shipping_charge&gt;&lt;shipping_total&gt;20.00&lt;/shipping_total&gt;&lt;shipping_allowance&gt;0&lt;/shipping_allowance&gt;&lt;amount_ins&gt;0&lt;/amount_ins&gt;&lt;order_create_date&gt;2013-04-27&lt;/order_create_date&gt;&lt;amount_disc&gt;&lt;/amount_disc&gt;&lt;bfirst&gt;James&lt;/bfirst&gt;&lt;blast&gt;James&lt;/blast&gt;&lt;baddr1&gt;Jewell&lt;/baddr1&gt;&lt;baddr2&gt;&lt;/baddr2&gt;&lt;bcity&gt;Cincinnati&lt;/bcity&gt;&lt;bstate&gt;OH&lt;/bstate&gt;&lt;bcountry&gt;US&lt;/bcountry&gt;&lt;bzip&gt;45255&lt;/bzip&gt;&lt;sfirst&gt;James&lt;/sfirst&gt;&lt;slast&gt;James&lt;/slast&gt;&lt;saddr1&gt;Jewell&lt;/saddr1&gt;&lt;saddr2&gt;&lt;/saddr2&gt;&lt;scity&gt;Cincinnati&lt;/scity&gt;&lt;sstate&gt;OH&lt;/sstate&gt;&lt;scountry&gt;US&lt;/scountry&gt;&lt;szip&gt;45255&lt;/szip&gt;&lt;carrier_code&gt;UPS&lt;/carrier_code&gt;&lt;dob&gt;1970-01-01&lt;/dob&gt;&lt;creditcard_number&gt;5434651900577797&lt;/creditcard_number&gt;&lt;card_type&gt;M&lt;/card_type&gt;&lt;card_expire_date&gt;01/14&lt;/card_expire_date&gt;&lt;Customer_Email&gt;jamesnjewell@yahoo.com&lt;/Customer_Email&gt;&lt;CV_Code&gt;123&lt;/CV_Code&gt;&lt;ChallengeQuestion&gt;&lt;/ChallengeQuestion&gt;&lt;ChallengeAnswer&gt;&lt;/ChallengeAnswer&gt;&lt;localeSetting&gt;&lt;/localeSetting&gt;&lt;ignoreAddressValidation&gt;true&lt;/ignoreAddressValidation&gt;&lt;auth_code&gt;&lt;/auth_code&gt;&lt;affiliate_code&gt;&lt;/affiliate_code&gt;&lt;/oOrderRequest&gt;&lt;/CreateOrder&gt;
  2013-04-27 05:22:42.817889 nusoap_client: got wsdl error: phpType is struct, but value is not an array: see debug output for details
  </code></pre>
  
  <p>I'm still fairly new to using soap/nusoap, but I do believe that the error is the xml value I am passing in directly.  If I remove the line <code>'orderItems' =&gt; $orderItemRequest,</code>, I do not get the error.  Is there any way to put multiple arrays with the same key into the same array?</p>