Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $cost_string = file_get_contents("/aws_data/ec2prices.json");
- $cost_arr = json_decode($cost_string,true);
- $costs_regions = $cost_arr['regions'];
- foreach ($costs_regions as $region){
- $regions = $region['region'];
- $prices = $region['instanceTypes'];
- foreach ($prices as $price){
- $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']);
- }
- }
- $oldCostJson = json_encode($oldCost_array);
- $newCostStr = file_get_contents("/aws_data/ec2prices_latest.json");
- $newCost_arr = json_decode($newCostStr,true);
- $newCost_regions = $newCost_arr['regions'];
- foreach($newCost_regions as $newRegion){
- $newPrices = $newRegion['instanceTypes'];
- foreach ($newPrices as $new_price){
- $newCost_array[] = json_decode($oldCostJson,true);
- array_push($newCost_array, array('new_price'=>$new_price['price']));
- }
- }
- $newCost = json_encode($newCost_array);
Add Comment
Please, Sign In to add comment