konst1977 Posted November 27, 2007 Share Posted November 27, 2007 Hi! I have two arrays - $cab & $cab2, then I have to combine them into one array $temparray & the keys should be "addressbook". Currently I use array("addressbook" => $cab, $cab2), but as a result only one key has value "addressbook" another one has value "0" (pls see the pic). How to create an array with both keys "addressbook" or how to rename "0" to "addressbook"? Thanks in advance (php 5.2.x). $cab = array("defaultBilling" => "true", "defaultShipping"=> "false", "label" => $streetn, "addressee" => $fullname, "addr1" => $streetn, "phone" => $phonen, "state" => $staten, "zip" => $zipn, "country" => "_unitedStates", "city" => $cityn); $cab2 = array("defaultBilling" => "false", "defaultShipping"=> "true", "label" => $streetn2, "addressee" => $fullname2, "addr1" => $streetn2, "phone" => $phonen, "state" => $staten2, "zip" => $zipn2, "country" => "_unitedStates", "city" => $cityn2); $temparray = array("addressbook" => $cab, $cab2); [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Orio Posted November 27, 2007 Share Posted November 27, 2007 Your whole post is a mess... Try explaining what exactly each array contains (give examples), and define exactly what you want to end up with (again, examples would be helpful). Orio. Quote Link to comment Share on other sites More sharing options...
konst1977 Posted November 27, 2007 Author Share Posted November 27, 2007 Sorry, so I have two arrays - $cab & $cab2 each filled with 10 pairs of string values/keys (basically they are two addresses - shipping a billing ). Then I have to combine them into one array (to send it to a web-service). This array should have two entries with both keys equal to "addressbook" and values respectively arrays ($cab & $cab2). Since I'm a PHP newbie I don't know what type of an array (associative, list, etc...), hopefully you'll be able to figure it from a picture (picture is from Zend Studio debugger). I'm able to create the array I need but the problem is that one key value is "0" instead of "addressbook" (as you can see on the attached picture) and the webservice doesn't accept it. So how to make the second key to be "addressbook" instead of "0". To simplify the example, let's say: $cab = array("addressee" => "John Sheldon", "addr1" => "3638 25th Avenue", "city" => "New York"); $cab2 = array("addressee" => "Gavin Newsom", "addr1" => "15 Market St.", "city" => "San Francisco"); $temparray = array("addressbook" => $cab, $cab2); Tks a lot! Quote Link to comment Share on other sites More sharing options...
Orio Posted November 27, 2007 Share Posted November 27, 2007 The keys of an array must be unique. You can't have two values that have the same key... Orio. Quote Link to comment Share on other sites More sharing options...
konst1977 Posted November 27, 2007 Author Share Posted November 27, 2007 hmm... gotcha... what should I do then, the web service need this sort of soap request (generated with .net): addressbookList { addressbook { boolean defaultShipping = false boolean defaultBilling = true string label = Shipping Address string attention = John W Sheldon string addressee = John W Sheldon int phone = 345345555 string addr1 = addrrss77 string city = SF int zip = 43459 string state = _arizona } addressbook { boolean defaultShipping = true boolean defaultBilling = false string label = Shipping Address2 string addressee = Test integer phone = 3434535345 string addr1 = address test string city = New York int zip = 78901 string state = _alaska } } however, the custom libraries which I use to generate soap requests need arrays, and my array generated from PHP looks like and it's rejected by the web service: addressbookList { addressbook { boolean defaultBilling = true boolean defaultShipping = false string label = address15 string addressee = John X Sheldon string addr1 = address15 integer phone = 3453453455 string state = _california int zip = 94110 string country = _unitedStates string city = SF } __numeric_0 { boolean defaultBilling = false boolean defaultShipping = true string label = address2 string addressee = John2 X Sheldon2 string addr1 = address2 integer phone = 3453453455 string state = _alaska int zip = 12345 string country = _unitedStates string city = SF2 } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.