-
Notifications
You must be signed in to change notification settings - Fork 0
/
get.php
32 lines (25 loc) · 1000 Bytes
/
get.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?
$data = json_decode(file_get_contents('test.json'), true);
$pricebreaks = array();
$products=array();
foreach($data['Products'] as $p) {
print var_dump(isset($p['StandardPricing'])); print var_dump(isset($p['Packaging']));
if(isset($p['StandardPricing']) && isset($p['Packaging']) ) {
$products[$p['DigiKeyPartNumber']] = array('prices' => array(), 'packaging' => $p['Packaging']['Value']);
foreach($p['StandardPricing'] as $s) {
$products[$p['DigiKeyPartNumber']]['prices'][$s['BreakQuantity']] = $s['UnitPrice'];
}
}
}
print_r($products);
if(is_array($data['ExactManufacturerProducts']) && count($data['ExactManufacturerProducts'])) {
$pr = $data['ExactManufacturerProducts'][0];
$pricing = array($products[$pr['DigiKeyPartNumber']]);
if(is_array($pr['AlternatePackaging']) && count($pr['AlternatePackaging']) > 0) {
foreach($pr['AlternatePackaging'] as $ap) {
$pricing[]=$products[$ap['DigiKeyPartNumber']];
}
}
print_r($pricing);
}
?>