Pass entire Array in php in another array - php

I have array with products its name is $item
Array
(
[0] => Array
(
[Quantity] => 2
[Product] => Array
(
[Name] => Barbula klandoa - Caryopteris clandonensis
[UnitPrice] => Array
(
[Gross] => 1480
[Net] => 0
[Tax] => 0
[TaxRate] => 0
[CurrencyCode] => PLN
)
)
)
[1] => Array
(
[Quantity] => 1
[Product] => Array
(
[Name] => Aronia czarnoowocowa Nero - Aronia melanocarpa Nero
[UnitPrice] => Array
(
[Gross] => 1200
[Net] => 0
[Tax] => 0
[TaxRate] => 0
[CurrencyCode] => PLN
)
)
)
[2] => Array
(
[Quantity] => 1
[Product] => Array
(
[Name] => Ambrowiec AmerykaƄski P9 - Liquidambar styraciflua
[UnitPrice] => Array
(
[Gross] => 1300
[Net] => 0
[Tax] => 0
[TaxRate] => 0
[CurrencyCode] => PLN
)
)
)
)
no i have to passed it to this:
$shoppingCart = array(
'GrandTotal' => ($suma_z_produktow*10),
'CurrencyCode' => 'PLN',
'ShoppingCartItems' => array (
array ('ShoppingCartItem' => $item)
)
);
Result is that only last entry from this array is passed to this new array.
I can nodifi it and pass it like that:
$shoppingCart = array(
'GrandTotal' => ($suma_z_produktow*10),
'CurrencyCode' => 'PLN',
'ShoppingCartItems' => array (
array ('ShoppingCartItem' => $item[0)
array ('ShoppingCartItem' => $item[1)
)
);
that method works, but I dont know how many product will customer order. Is there any method to pass all items in 1 row?
Its for Payu Payment method integration.
Thx

I think you need to tweak your code to get it to do what you want. Here is what I would recommend:
$shoppingCart = array(
'GrandTotal' => ($suma_z_produktow*10),
'CurrencyCode' => 'PLN',
'ShoppingCartItems' => array (),
);
foreach($item as $product) {
$shoppingCart['ShoppingCartItems'][] = array('ShoppingCartItem' => $product);
}

Try this:
$shoppingCart = array(
'GrandTotal' => ($suma_z_produktow*10),
'CurrencyCode' => 'PLN',
'ShoppingCartItems' => array (),
);
foreach($item as $cartItem){
$shoppingCart['ShoppingCartItems'][] = array('ShoppingCartItem'=>$cartItem);
}
print_r($shoppingCart);
This will build up the shoppingCartItems for as many items as you have.

Related

search inside arrays with condition in php

I have an api with a list of arrays inside one array and each array inside this array it has one key [attributes] and inside this key one array with key [CITY_NAME]
this is my array coming from api
this array number is 0 but every day this number is changed and my figures come wrong, what is the good way to always have my city figures using the key [CITY_NAME]
I am fetching the data using this code
$json = file_get_contents($url);
$json_data = json_decode($json, true);
$data = $json_data['features'];
$mycity = $data[0]['attributes'];
Array
(
[0] => Array
(
[attributes] => Array
(
[CITY_NAME] => city1
[Name] => city1
[ADMIN_NAME] => city1
[POP_CLASS] => 5,000,000 to10,000,000
[Population] => 7676654
[Population_Data_Source] => Wikipedia
[Population_Data_Date] => 2018
[CityID] => 14
[Longitude] => 46.7614868685786
[Latitude] => 24.7388786516234
[Confirmed] => 0
[Recovered] => 0
[Deaths] => 0
[Active] => 0
[Tested] => 0
[Name_Eng] => city1
[Join_Count] => 61
[Confirmed_SUM] => 5152
[Deaths_SUM] => 9
[Recovered_SUM] => 1407
[Active_SUM] => 3736
[Tested_SUM] => 376607
[ObjectId] => 14
)
)
[1] => Array
(
[attributes] => Array
(
[CITY_NAME] => city2
[Name] => city2
[ADMIN_NAME] => city2
[POP_CLASS] => 1,000,000 to 5,000,000
[Population] => 1675368
[Population_Data_Source] => Wikipedia
[Population_Data_Date] => 2010
[CityID] => 9
[Longitude] => 39.8148987363852
[Latitude] => 21.4273876500039
[Confirmed] => 0
[Recovered] => 0
[Deaths] => 0
[Active] => 0
[Tested] => 0
[Name_Eng] => city2
[Join_Count] => 59
[Confirmed_SUM] => 6848
[Deaths_SUM] => 85
[Recovered_SUM] => 1145
[Active_SUM] => 5618
[Tested_SUM] => 0
[ObjectId] => 9
)
)
Since I may have misunderstood and you may have many, just build a new array with CITY_NAME:
foreach($data as $values) {
$result[$values['attributes']['CITY_NAME']] = $values['attributes'];
}
Now you can access by CITY_NAME:
echo $result['city1']['Population'];
This might be easier. Extract all attributes from all arrays into an array, then create an array from that indexed by CITY_NAME:
$data = array_column(array_column($json_data['features'], 'attributes'),
null, 'CITY_NAME');

I got this response from cleeng API ; how to convert this response to JSON

Cleeng_Entity_Collection Object
(
[entityType:protected] => Cleeng_Entity_SubscriptionOffer
[items:protected] => Array
(
[0] => Cleeng_Entity_SubscriptionOffer Object
(
[id:protected] => S955494970_US
[publisherEmail:protected] => vidya+mtc#ooyala.com
[url:protected] =>
[title:protected] => Annual subscription
[description:protected] =>
[period:protected] => year
[price:protected] => 49.99
[applicableTaxRate:protected] => 0
[currency:protected] => USD
[accessToTags:protected] => Array
(
[0] => d962607d3d4c4e3c98a343c7bcb64027
)
[active:protected] => 1
[createdAt:protected] => 1473681112
[updatedAt:protected] => 1473858745
[geoRestrictionEnabled:protected] =>
[geoRestrictionType:protected] =>
[geoRestrictionCountries:protected] => Array
(
)
[pending:protected] =>
[country] => US
[socialCommissionRate] => 0
[averageRating] => 4
[contentType] =>
[freePeriods] => 0
[freeDays] => 0
[expiresAt] =>
)
)
[totalItemCount:protected] => 5
[pending:protected] =>
)
All you need to do is just convert the Collection to a Regular Array and then json_encode() the Result like so:
<?php
$entityCollection = "???"; // THIS IS THE DATA FROM Cleeng_Entity_Collection Object
$entityArray = $entityCollection->toArray();
$entityJSON = json_encode($entityArray);

how to display an array converted from xml

I have an Array which i got after converting from an XML, This XML is coming from amazon seller account. It has got all the orders which are available in my seller account.
Im using Yii 2.0 php framework, Im passing this array to view after converting from XML to array in controller. This is my array..
Array
(
[ListOrdersResult] => Array
(
[CreatedBefore] => 2016-07-11T05:59:05Z
[Orders] => Array
(
[Order] => Array
(
[0] => Array
(
[AmazonOrderId] => 171-4557760-7388350
[PurchaseDate] => 2016-06-01T13:07:46Z
[LastUpdateDate] => 2016-06-03T12:43:26Z
[OrderStatus] => Canceled
[FulfillmentChannel] => MFN
[SalesChannel] => Amazon.in
[ShipServiceLevel] => IN Exp Dom 2
[OrderTotal] => Array
(
[CurrencyCode] => INR
[Amount] => 40.00
)
[NumberOfItemsShipped] => 0
[NumberOfItemsUnshipped] => 0
[PaymentExecutionDetail] => Array
(
)
[MarketplaceId] => A21TJRUUN4KGV
[ShipmentServiceLevelCategory] => Expedited
[ShippedByAmazonTFM] => false
[OrderType] => StandardOrder
[EarliestShipDate] => 2016-06-01T18:30:00Z
[LatestShipDate] => 2016-06-03T18:29:59Z
[IsPrime] => false
[IsPremiumOrder] => false
)
[1] => Array
(
[AmazonOrderId] => 403-4718683-0373128
[PurchaseDate] => 2016-06-03T12:30:20Z
[LastUpdateDate] => 2016-06-03T14:02:13Z
[OrderStatus] => Canceled
[FulfillmentChannel] => MFN
[SalesChannel] => Amazon.in
[ShipServiceLevel] => IN Exp Dom 2
[OrderTotal] => Array
(
[CurrencyCode] => INR
[Amount] => 40.00
)
[NumberOfItemsShipped] => 0
[NumberOfItemsUnshipped] => 0
[PaymentExecutionDetail] => Array
(
)
[MarketplaceId] => A21TJRUUN4KGV
[ShipmentServiceLevelCategory] => Expedited
[ShippedByAmazonTFM] => false
[OrderType] => StandardOrder
[EarliestShipDate] => 2016-06-03T18:30:00Z
[LatestShipDate] => 2016-06-06T18:29:59Z
[IsPrime] => false
[IsPremiumOrder] => false
)
)
)
)
[ResponseMetadata] => Array
(
[RequestId] => 42c3353b-d6af-459f-9421-5e8b7efb8ea8
)
)
Here each array is am order, Now i want to display one by one.. can anyone kindly help me how to i display.. Im using Yii2 Php framework for this project... Thank you..
It should be something like this:
$myArray['ListOrdersResult']['Orders']['Order'][0]['AmazonOrderId'] = '171-4557760-7388350';
function print_order($order) {
foreach ($order as $key1=>$val) {
if (is_array($val))
print_order($val);
else
print "$key1 = $val<br/>\r\n";
}
}
print_order($myArray['ListOrdersResult']['Orders']['Order']);

PHP Object with array of objects finding key/value and linking it with another key/value pair

PROGRESS: Almost there... Need help on the last bit!!!
$users = $client->getAccounts();
$num = count($users);
for ( $x=0; $x < $num; $x++){
foreach($users[$x] as $y => $y_value) {
if($y_value == iLy){
print_r($y);
echo '<br>';
print_r($x);
echo '<br>';
print_r($user[$x]["id"]);
}
}
}
Above is the latest bit of code I have written and I have been to locate the array value or the array I am looking for by search by name. print_r($user[$x]["id"]);
Results in:
Warning: Illegal string offset 'id' in /home/examplesite/BLANK.com/CBapi.php on line 37
I used this simplification to discover the logic for my solution:
This works
<?php
$age = array (array("name"=>"iLy", "id"=>"37", "balance"=>"43"),
array("name"=>"jim", "id"=>"67", "balance"=>"47"));
echo $age[0]['id'];
$num = count($age);
for ( $x=0; $x < $num; $x++){
foreach($age[$x] as $y => $y_value) {
if($y_value == 43){
print_r($y);
echo '<br>';
print_r($x);
echo '<br>';
print_r($age[$x]["id"]);
}
}
}
?>
I believe I am just calling the wrong Key Name.
++++++++++++++++++++++ Original Post Below ++++++++++++++++++++++
Current code:
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$configuration->setApiUrl(Configuration::SANDBOX_API_URL);
$client = Client::create($configuration);
$users = $client->getAccounts();
I have been struggling with this for four days now... I used function below and it returns an object which contains an array of objects. My goal is to search through the collection of objects for a key and value, (For example to search the name of a current user:$currentuser = 'iLy'; $user = $currentuser; Then I could identify the array value, which would be $users[2] for our example 'iLy' to search the key value 'id', to get the $accountId.
Ideally I could search 'name' => iLy and have it return the 'id' => 'xxxxxxx' in that same array.
When I create accounts this is the only way I have been able to figure out how to get the accountID, and I haven't found any other API calls to get the account by name. I have only been able to isolate one object using $users[2]. I know this may be a repeat post, but I haven't been able to make any of the other solutions work.
PHP - find entry by object property from a array of objects , Array of PHP Objects
Maybe I am using the wrong solutions or applying them wrong. Any help would be greatly appreciated!
public function getAccounts(array $params = [])
{
return $this->getAndMapCollection('/v2/accounts',$params,'toAccounts');
}
Returns this:
Coinbase\\Wallet\\Resource\\ResourceCollection Object (
[previousUri:Coinbase\\Wallet\\Resource\\ResourceCollection:private] =>
[nextUri:Coinbase\\Wallet\\Resource\\ResourceCollection:private] =>
[resources:Coinbase\\Wallet\\Resource\\ResourceCollection:private] => Array (
[0] => Coinbase\\Wallet\\Resource\\Account Object (
[name:Coinbase\\Wallet\\Resource\\Account:private] => Jennaod3
[primary:Coinbase\\Wallet\\Resource\\Account:private] =>
[type:Coinbase\\Wallet\\Resource\\Account:private] => wallet
[currency:Coinbase\\Wallet\\Resource\\Account:private] => BTC
[balance:Coinbase\\Wallet\\Resource\\Account:private] => Coinbase\\Wallet\\Value\\Money Object (
[amount:Coinbase\\Wallet\\Value\\Money:private] => 0.00000000
[currency:Coinbase\\Wallet\\Value\\Money:private] => BTC
)
[nativeBalance:Coinbase\\Wallet\\Resource\\Account:private] => Coinbase\\Wallet\\Value\\Money Object (
[amount:Coinbase\\Wallet\\Value\\Money:private] => 0.00
[currency:Coinbase\\Wallet\\Value\\Money:private] => USD
)
[createdAt:Coinbase\\Wallet\\Resource\\Account:private] => DateTime Object (
[date] => 2016-05-24 04:55:41.000000
[timezone_type] => 2
[timezone] => Z
)
[updatedAt:Coinbase\\Wallet\\Resource\\Account:private] => DateTime Object (
[date] => 2016-05-24 04:55:41.000000
[timezone_type] => 2
[timezone] => Z
)
[id:Coinbase\\Wallet\\Resource\\Resource:private] => 0d41fc45-0a53-58cb-9931-c9a33f520963
[resource:Coinbase\\Wallet\\Resource\\Resource:private] => account
[resourcePath:Coinbase\\Wallet\\Resource\\Resource:private] => /v2/accounts/0d41fc45-0a53-58cb-9931-c9a33f520963
[rawData:Coinbase\\Wallet\\Resource\\Resource:private] => Array (
[id] => 0d41fc45-0a53-58cb-9931-c9a33f520963
[name] => Jennaod3
[primary] =>
[type] => wallet
[currency] => BTC
[balance] => Array (
[amount] => 0.00000000
[currency] => BTC
)
[native_balance] => Array (
[amount] => 0.00
[currency] => USD
)
[created_at] => 2016-05-24T04:55:41Z
[updated_at] => 2016-05-24T04:55:41Z
[resource] => account
[resource_path] => /v2/accounts/0d41fc45-0a53-58cb-9931-c9a33f520963
)
)
[1] => Coinbase\\Wallet\\Resource\\Account Object (
[name:Coinbase\\Wallet\\Resource\\Account:private] => jenna works to
[primary:Coinbase\\Wallet\\Resource\\Account:private] =>
[type:Coinbase\\Wallet\\Resource\\Account:private] => wallet
[currency:Coinbase\\Wallet\\Resource\\Account:private] => BTC
[balance:Coinbase\\Wallet\\Resource\\Account:private] => Coinbase\\Wallet\\Value\\Money Object (
[amount:Coinbase\\Wallet\\Value\\Money:private] => 0.00000000
[currency:Coinbase\\Wallet\\Value\\Money:private] => BTC
)
[nativeBalance:Coinbase\\Wallet\\Resource\\Account:private] => Coinbase\\Wallet\\Value\\Money Object (
[amount:Coinbase\\Wallet\\Value\\Money:private] => 0.00
[currency:Coinbase\\Wallet\\Value\\Money:private] => USD
)
[createdAt:Coinbase\\Wallet\\Resource\\Account:private] => DateTime Object (
[date] => 2016-05-22 13:37:16.000000
[timezone_type] => 2
[timezone] => Z
)
[updatedAt:Coinbase\\Wallet\\Resource\\Account:private] => DateTime Object (
[date] => 2016-05-22 13:37:16.000000
[timezone_type] => 2
[timezone] => Z
)
[id:Coinbase\\Wallet\\Resource\\Resource:private] => e7ab48b4-bc76-513a-a78b-6d627f32f848
[resource:Coinbase\\Wallet\\Resource\\Resource:private] => account
[resourcePath:Coinbase\\Wallet\\Resource\\Resource:private] => /v2/accounts/e7ab48b4-bc76-513a-a78b-6d627f32f848
[rawData:Coinbase\\Wallet\\Resource\\Resource:private] => Array (
[id] => e7ab48b4-bc76-513a-a78b-6d627f32f848
[name] => jenna works to
[primary] =>
[type] => wallet
[currency] => BTC
[balance] => Array (
[amount] => 0.00000000
[currency] => BTC
)
[native_balance] => Array (
[amount] => 0.00
[currency] => USD
)
[created_at] => 2016-05-22T13:37:16Z
[updated_at] => 2016-05-22T13:37:16Z
[resource] => account
[resource_path] => /v2/accounts/e7ab48b4-bc76-513a-a78b-6d627f32f848
)
)
[2] => Coinbase\\Wallet\\Resource\\Account Object (
[name:Coinbase\\Wallet\\Resource\\Account:private] => iLy
[primary:Coinbase\\Wallet\\Resource\\Account:private] =>
[type:Coinbase\\Wallet\\Resource\\Account:private] => wallet
[currency:Coinbase\\Wallet\\Resource\\Account:private] => BTC
[balance:Coinbase\\Wallet\\Resource\\Account:private] => Coinbase\\Wallet\\Value\\Money Object (
[amount:Coinbase\\Wallet\\Value\\Money:private] => 0.00000000
[currency:Coinbase\\Wallet\\Value\\Money:private] => BTC
)
[nativeBalance:Coinbase\\Wallet\\Resource\\Account:private] => Coinbase\\Wallet\\Value\\Money Object (
[amount:Coinbase\\Wallet\\Value\\Money:private] => 0.00
[currency:Coinbase\\Wallet\\Value\\Money:private] => USD
)
[createdAt:Coinbase\\Wallet\\Resource\\Account:private] => DateTime Object (
[date] => 2016-05-22 13:33:36.000000
[timezone_type] => 2
[timezone] => Z
)
[updatedAt:Coinbase\\Wallet\\Resource\\Account:private] => DateTime Object (
[date] => 2016-05-22 13:33:36.000000
[timezone_type] => 2
[timezone] => Z
)
[id:Coinbase\\Wallet\\Resource\\Resource:private] => c95fd701-cf2b-56f7-b438-9a2f0e61b21c
[resource:Coinbase\\Wallet\\Resource\\Resource:private] => account
[resourcePath:Coinbase\\Wallet\\Resource\\Resource:private] => /v2/accounts/c95fd701-cf2b-56f7-b438-9a2f0e61b21c
[rawData:Coinbase\\Wallet\\Resource\\Resource:private] => Array (
[id] => c95fd701-cf2b-56f7-b438-9a2f0e61b21c
[name] => iLy
[primary] =>
[type] => wallet
[currency] => BTC
[balance] => Array (
[amount] => 0.00000000
[currency] => BTC
)
[native_balance] => Array (
[amount] => 0.00
[currency] => USD
)
[created_at] => 2016-05-22T13:33:36Z
[updated_at] => 2016-05-22T13:33:36Z
[resource] => account
[resource_path] => /v2/accounts/c95fd701-cf2b-56f7-b438-9a2f0e61b21c
)
)
[3] => Coinbase\\Wallet\\Resource\\Account Object (
[name:Coinbase\\Wallet\\Resource\\Account:private] => BTC Wallet
[primary:Coinbase\\Wallet\\Resource\\Account:private] => 1
[type:Coinbase\\Wallet\\Resource\\Account:private] => wallet
[currency:Coinbase\\Wallet\\Resource\\Account:private] => BTC
[balance:Coinbase\\Wallet\\Resource\\Account:private] => Coinbase\\Wallet\\Value\\Money Object (
[amount:Coinbase\\Wallet\\Value\\Money:private] => 0.10000000
[currency:Coinbase\\Wallet\\Value\\Money:private] => BTC
)
[nativeBalance:Coinbase\\Wallet\\Resource\\Account:private] => Coinbase\\Wallet\\Value\\Money Object (
[amount:Coinbase\\Wallet\\Value\\Money:private] => 1000.00
[currency:Coinbase\\Wallet\\Value\\Money:private] => USD
)
[createdAt:Coinbase\\Wallet\\Resource\\Account:private] => DateTime Object (
[date] => 2016-05-21 02:41:13.000000
[timezone_type] => 2
[timezone] => Z
)
[updatedAt:Coinbase\\Wallet\\Resource\\Account:private] => DateTime Object (
[date] => 2016-05-21 02:41:14.000000
[timezone_type] => 2
[timezone] => Z
)
[id:Coinbase\\Wallet\\Resource\\Resource:private] => 0e0dac44-6900-59e9-8183-99b9459d1205
[resource:Coinbase\\Wallet\\Resource\\Resource:private] => account
[resourcePath:Coinbase\\Wallet\\Resource\\Resource:private] => /v2/accounts/0e0dac44-6900-59e9-8183-99b9459d1205
[rawData:Coinbase\\Wallet\\Resource\\Resource:private] => Array (
[id] => 0e0dac44-6900-59e9-8183-99b9459d1205
[name] => BTC Wallet
[primary] => 1
[type] => wallet
[currency] => BTC
[balance] => Array (
[amount] => 0.10000000
[currency] => BTC
)
[native_balance] => Array (
[amount] => 1000.00
[currency] => USD
)
[created_at] => 2016-05-21T02:41:13Z
[updated_at] => 2016-05-21T02:41:14Z
[resource] => account
[resource_path] => /v2/accounts/0e0dac44-6900-59e9-8183-99b9459d1205
)
)
)
)
This was my answer and it isn't pretty. It turns out I had to make some of the variables public in the API resource file, which I'm not sure if that was a good idea, but it achieved my goal using this code:
$users = $client->getAccounts();
$num = count($users);
for ( $x=0; $x < $num; $x++){
foreach($users[$x] as $y => $y_value) {
if($y_value == iLy) {
$bae = $users[$x];
$account_id = '';
foreach ($bae as $k => $k_value) {
$account_id = $k_value;
}
}
}
}
It seems as though all my arrays were objects and the only way I could obtain the values I needed was by using foreach loops.

How to echo an array value

I am fairly new to PHP and I am writing a PHP function that grabs an object from SOAP.
I found a code to convert it to an array but I can't manage to echo any data.
The array from print_r
Array
(
[Status] => Array
(
[Code] => 0
[Message] => OK
)
[Order] => Array
(
[OrderNumber] => 9334543
[ExternalOrderNumber] =>
[OrderTime] => 2014-07-15T15:20:31+02:00
[PaymentMethod] => invoice
[PaymentStatus] => Paid
[ShipmentMethod] => Mypack
[DeliveryStatus] => Delivered
[Language] => sv
[Customer] => Array
(
[CustomerId] => 13556
[CustomerNumber] =>
[Username] => admin
[Approved] => 1
[OrgNumber] => 9309138445
[Company] =>
[VatNumber] =>
[FirstName] => Jane
[LastName] => Doe
[Address] => Gatan
[Address2] =>
[Zip] => 1230
[City] => Staden
[Country] => Sweden
[CountryCode] => SE
[PhoneDay] => 84848474
[PhoneNight] =>
[PhoneMobile] =>
[Email] => mail#msn.com
[NewsLetter] =>
[OrgType] => person
[OtherDelivAddress] =>
[DelivName] =>
[DelivAddress] =>
[DelivAddress2] =>
[DelivZip] =>
[DelivCity] =>
[DelivCountry] =>
[DelivCountryCode] =>
)
[Comment] =>
[Notes] => 9063025471 UK/MA
[CurrencyCode] => SEK
[ExchangeRate] => 1
[LanguagePath] => se
[FreightWithoutVat] => 0
[FreightWithVat] => 0
[FreightVatPercentage] => 25
[PayoptionFeeWithoutVat] => 0
[PayoptionFeeWithVat] => 0
[PayoptionFeeVatPercentage] => 25
[CodWithoutVat] => 0
[CodWithVat] => 0
[CodVatPercentage] => 0
[DiscountWithoutVat] => 0
[DiscountWithVat] => 0
[DiscountVat] => 0
[TotalWithoutVat] => 4388
[TotalWithVat] => 5485
[TotalVat] => 1097
[PayWithoutVat] =>
[AffiliateCode] =>
[AffiliateName] =>
[OrderField] => Array
(
[0] => Array
(
[Name] => external_ref
[Value] => 43445
)
[1] => Array
(
[Name] => webshopid
[Value] => 423
)
[2] => Array
(
[Name] => webshopname
[Value] => Manuell
)
)
)
)
Non working code
echo $array[1][0]
I have tried different combos of indexes. I know how to return the values from the soap object but if I could do it this way it would be easier. It should work shouldn't it?
$array[1] is the second index of the array. the key of this array us "Status", this array contains a code and message
i assume you want to echo the message, you can do that with the following
echo $array[1]["Status"]["Message"];
You should use $array['Status']['Code'] , $array['Status']['Message'], $array['Order']['OrderNumber'], $array['Order']['Customer']['CustomerId'] and so on to display your data. It's an associative array so you need to use string keys and not numbers
try
$array['Order']['Customer']['LastName']
is my best guess without losing my sanity in that one line.
But for us to be sure please post the print_r($array) output
There are some way I always do this:
print_r($array);
And the other way is
$array[0]['Order']['LastName']
Try to access the arrays elements with the string keys, not the integer ones you are using:
echo $array['Order']['Customer']['Address'];
Another way you could see what is going on is by iterating through the array, and print out the keys and values:
foreach ($array as $key => $value)
echo "Key=$key value=$value<br>";

Categories