Guest User

Untitled

a guest
Aug 29th, 2016
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. $cost_string = file_get_contents("/aws_data/ec2prices.json");
  2. $cost_arr = json_decode($cost_string,true);
  3. $costs_regions = $cost_arr['regions'];
  4. foreach ($costs_regions as $region){
  5. $regions = $region['region'];
  6. $prices = $region['instanceTypes'];
  7. foreach ($prices as $price){
  8.  
  9. $oldCost_array[] = array('region'=> $region['region'],'type'=>$price['type'],'os'=> $price['os'],'price'=>$price['prices']['ondemand']['hourly'],'new_price'=>'','utilization'=>$price['utilization'],'upfront'=>$price ['prices']['ondemand']['upfront_perGB']);
  10. }
  11. }
  12.  
  13. $oldCostJson = json_encode($oldCost_array);
  14.  
  15. $newCostStr = file_get_contents("/aws_data/ec2prices_latest.json");
  16. $newCost_arr = json_decode($newCostStr,true);
  17. $newCost_regions = $newCost_arr['regions'];
  18. foreach($newCost_regions as $newRegion){
  19. $newPrices = $newRegion['instanceTypes'];
  20. foreach ($newPrices as $new_price){
  21. $newCost_array[] = json_decode($oldCostJson,true);
  22. array_push($newCost_array, array('new_price'=>$new_price['price']));
  23.  
  24. }
  25. }
  26. $newCost = json_encode($newCost_array);
Add Comment
Please, Sign In to add comment