array (
'125100 - 33166' =>
array (
'ReferenceNumber' => '125100',
'ShipDate' => '9/12/2016',
'ShipToName' => 'APOLLO EXPORT WAREHOUSE',
'ShipToCompany' => 'c/o Dry Non Bonded Consolidator',
'ShipToAddress1' => '6950 N.W. 77th Court',
'ShipToAddress2' => 'Attn: Alejandro Garcia 305-592-8790 x80',
'ShipToCity' => 'Miami',
'ShipToState' => 'FL',
'ShipToZip' => '33166',
'ShipToContact' => '',
'ShipCarrier' => 'UPS',
'PurchaseOrderNumber' => '10020822001',
'Data' =>
array (
0 =>
array (
0 => 'HBX43C',
1 => 'HBX43C - Norwegian Custom Nespresso Tray
Dimensions: 10.75”x14.75”x Front 2”hx Back 3”h
Leather: Black Faux Leather
Thread: Black
Custom Details: removable compartments; acrylic pod & creamer holders
No velcro on rubber mat
Case pack: 6
UPC: 697182429431',
2 => '12',
3 => '',
),
),
),
'125101 - 33166' =>
array (
'ReferenceNumber' => '125101',
'ShipDate' => '9/12/2016',
'ShipToName' => 'APOLLO EXPORT WAREHOUSE',
'ShipToCompany' => 'c/o Dry Non Bonded Consolidator',
'ShipToAddress1' => '6950 N.W. 77th Court',
'ShipToAddress2' => 'Attn: Alejandro Garcia 305-592-8790 x80',
'ShipToCity' => 'Miami',
'ShipToState' => 'FL',
'ShipToZip' => '33166',
'ShipToContact' => '',
'ShipCarrier' => 'UPS',
'PurchaseOrderNumber' => '10020823001',
'Data' =>
array (
0 =>
array (
0 => 'HBX43C',
1 => 'HBX43C - Norwegian Custom Nespresso Tray
Dimensions: 10.75”x14.75”x Front 2”hx Back 3”h
Leather: Black Faux Leather
Thread: Black
Custom Details: removable compartments; acrylic pod & creamer holders
No velcro on rubber mat
Case pack: 6
UPC: 697182429431',
2 => '18',
3 => '',
),
),
),
'125102 - 33166' =>
array (
'ReferenceNumber' => '125102',
'ShipDate' => '9/12/2016',
'ShipToName' => 'APOLLO EXPORT WAREHOUSE',
'ShipToCompany' => 'c/o Dry Non Bonded Consolidator',
'ShipToAddress1' => '6950 N.W. 77th Court',
'ShipToAddress2' => 'Attn: Alejandro Garcia 305-592-8790 x80',
'ShipToCity' => 'Miami',
'ShipToState' => 'FL',
'ShipToZip' => '33166',
'ShipToContact' => '',
'ShipCarrier' => 'UPS',
'PurchaseOrderNumber' => '1.30E+11',
'Data' =>
array (
0 =>
array (
0 => 'HBX43C',
1 => 'HBX43C - Norwegian Custom Nespresso Tray
Dimensions: 10.75”x14.75”x Front 2”hx Back 3”h
Leather: Black Faux Leather
Thread: Black
Custom Details: removable compartments; acrylic pod & creamer holders
No velcro on rubber mat
Case pack: 6
UPC: 697182429431',
2 => '6',
3 => '',
),
),
),
'11WW111 - 81623' =>
array (
'ReferenceNumber' => '11WW111',
'ShipDate' => '9/12/2016',
'ShipToName' => 'test',
'ShipToCompany' => 'test',
'ShipToAddress1' => 'test',
'ShipToAddress2' => 'test',
'ShipToCity' => 'test',
'ShipToState' => 'CO',
'ShipToZip' => '81623',
'ShipToContact' => '',
'ShipCarrier' => 'TKN',
'PurchaseOrderNumber' => 'test',
'Data' =>
array (
0 =>
array (
0 => '1STTTTS4',
1 => 'test',
2 => '11',
3 => '',
),
),
),
'125103 - 81623' =>
array (
'ReferenceNumber' => '125103',
'ShipDate' => '9/12/2016',
'ShipToName' => 'Old Towne Moving & Storage',
'ShipToCompany' => '',
'ShipToAddress1' => '62 CR 113 Bldg H',
'ShipToAddress2' => 'Attn: Cody Pace 970-384-4444',
'ShipToCity' => 'Carbondale',
'ShipToState' => 'CO',
'ShipToZip' => '81623',
'ShipToContact' => '',
'ShipCarrier' => 'TKN',
'PurchaseOrderNumber' => 'LIMO-053',
'Data' =>
array (
0 =>
array (
0 => '39906B-LIME',
1 => '39906B-LIME - Matte Nickel Ice Tongs
*** Length: 6" ***
Casepack: 48',
2 => '144',
3 => '',
),
),
),
)
我如何HBX43C
从整个数组中查找以及在找到该元素之后如何获取在其中HBX43C
找到的该数组的整个块。
因此,如果HBX43C
发现我需要具备:
Array
(
[ReferenceNumber] => 125102
[ShipDate] => 9/12/2016
[ShipToName] => APOLLO EXPORT WAREHOUSE
[ShipToCompany] => c/o Dry Non Bonded Consolidator
[ShipToAddress1] => 6950 N.W. 77th Court
[ShipToAddress2] => Attn: Alejandro Garcia 305-592-8790 x80
[ShipToCity] => Miami
[ShipToState] => FL
[ShipToZip] => 33166
[ShipToContact] =>
[ShipCarrier] => UPS
[PurchaseOrderNumber] => 1.30E+11
[Data] => Array
(
[0] => Array
(
[0] => HBX43C
[1] => HBX43C - Norwegian Custom Nespresso Tray
Dimensions: 10.75”x14.75”x Front 2”hx Back 3”h
Leather: Black Faux Leather
Thread: Black
Custom Details: removable compartments; acrylic pod & creamer holders
No velcro on rubber mat
Case pack: 6
UPC: 697182429431
[2] => 6
[3] =>
)
)
)
作为HBX43C
包含在该阵列块。
我正在尝试的代码是:
$url = "https://www/www/contracts.asmx?wsdl";
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($soap_do, CURLOPT_URL, $url);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true);
curl_setopt($soap_do, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 10);
curl_setopt($soap_do, CURLOPT_POST, true);
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $soap_request);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"http://www.www.com/www/www.WMS/wwww\""
)
);
$response = curl_exec($soap_do);
if (strpos($response, 'Server was unable to process request') !== false) {
$full_response = explode(': ', $response, 2);
if (strpos($response, 'The following sku is not in the item list') !== false) {
$body .= $response;
foreach ($result as $item) {
foreach ($item['Data'] as $sub_item) {
if (in_array(trim($full_response[1]), $sub_item)) {
$body .= "SKU Number: " . $full_response[1];
print_r($sub_item);
break 2;
}
}
}
}
$body .= "<br /><br />";
$body .= "Used File: " . $files[2];
$body .= "<br /><br />";
echo $body;
echo "<br /><br />";
} else {
$body .= "Operation completed without any errors";
$body .= "<br /><br />";
$body .= "Used File: " . $files[2];
$body .= "<br /><br />";
echo $body;
echo "<br /><br />";
}
}
它似乎无法正常工作,因为它无法将全部障碍归还给我。
$full_response[1]
是 : HBX43C
$result
整个数组在哪里。
返回父数组条目,其中:
注意:该代码使用变量来存储中间结果,以使其易于遵循。
o搜索源列表中的所有条目
/**
* Search all the entries trying to find the needle in the 'nested' Data array
*
* @param array $srcArray
* @param string $needle
*
* @return array
*/
function searchHaystacks($srcArray, $needle)
{
$allMatches = array();
foreach ($srcArray as $key => $haystack) {
if (searchDataArray($haystack['Data'], $needle)) {
$allMatches[$key] = $haystack;
}
}
return $allMatches;
}
o“数据数组”搜索功能:
/**
* Give a Data array check if a given value is anywhere in it
* this is recursive.
*
* @param array $dataArray - Array to recursively search
* @param string $needle - value to match
* @return boolean - true if needle found in any of the nested arrays
*/
function searchDataArray($dataArray, $needle)
{
$matched = in_array($needle, $dataArray);
if ($matched) {
return true;
}
// any nested arrays?
foreach ($dataArray as $haystack) {
if (is_array($haystack)) { // another array to check
$matched = searchDataArray($haystack, $needle);
if ($matched) {
return true;
}
}
}
return false; // no array contains the needle
}
$needle = 'HBX43C';
$allNeedles = searchHaystacks($srcArray, $needle);
Matched Needles...
Array
(
[125100 - 33166] => Array
(
[ReferenceNumber] => 125100
[ShipDate] => 9/12/2016
[ShipToName] => APOLLO EXPORT WAREHOUSE
[ShipToCompany] => c/o Dry Non Bonded Consolidator
[ShipToAddress1] => 6950 N.W. 77th Court
[ShipToAddress2] => Attn: Alejandro Garcia 305-592-8790 x80
[ShipToCity] => Miami
[ShipToState] => FL
[ShipToZip] => 33166
[ShipToContact] =>
[ShipCarrier] => UPS
[PurchaseOrderNumber] => 10020822001
[Data] => Array
(
[0] => Array
(
[0] => HBX43C
[1] => HBX43C - Norwegian Custom Nespresso Tray
Dimensions: 10.75â€x14.75â€x Front 2â€hx Back 3â€h
Leather: Black Faux Leather
Thread: Black
Custom Details: removable compartments; acrylic pod & creamer holders
No velcro on rubber mat
Case pack: 6
UPC: 697182429431
[2] => 12
[3] =>
)
)
)
[125101 - 33166] => Array
(
[ReferenceNumber] => 125101
[ShipDate] => 9/12/2016
[ShipToName] => APOLLO EXPORT WAREHOUSE
[ShipToCompany] => c/o Dry Non Bonded Consolidator
[ShipToAddress1] => 6950 N.W. 77th Court
[ShipToAddress2] => Attn: Alejandro Garcia 305-592-8790 x80
[ShipToCity] => Miami
[ShipToState] => FL
[ShipToZip] => 33166
[ShipToContact] =>
[ShipCarrier] => UPS
[PurchaseOrderNumber] => 10020823001
[Data] => Array
(
[0] => Array
(
[0] => HBX43C
[1] => HBX43C - Norwegian Custom Nespresso Tray
Dimensions: 10.75â€x14.75â€x Front 2â€hx Back 3â€h
Leather: Black Faux Leather
Thread: Black
Custom Details: removable compartments; acrylic pod & creamer holders
No velcro on rubber mat
Case pack: 6
UPC: 697182429431
[2] => 18
[3] =>
)
)
)
[125102 - 33166] => Array
(
[ReferenceNumber] => 125102
[ShipDate] => 9/12/2016
[ShipToName] => APOLLO EXPORT WAREHOUSE
[ShipToCompany] => c/o Dry Non Bonded Consolidator
[ShipToAddress1] => 6950 N.W. 77th Court
[ShipToAddress2] => Attn: Alejandro Garcia 305-592-8790 x80
[ShipToCity] => Miami
[ShipToState] => FL
[ShipToZip] => 33166
[ShipToContact] =>
[ShipCarrier] => UPS
[PurchaseOrderNumber] => 1.30E+11
[Data] => Array
(
[0] => Array
(
[0] => HBX43C
[1] => HBX43C - Norwegian Custom Nespresso Tray
Dimensions: 10.75â€x14.75â€x Front 2â€hx Back 3â€h
Leather: Black Faux Leather
Thread: Black
Custom Details: removable compartments; acrylic pod & creamer holders
No velcro on rubber mat
Case pack: 6
UPC: 697182429431
[2] => 6
[3] =>
)
)
)
)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句