<?php // https://forum.airnowtech.org/t/the-aqi-equation/169 function aqiFromPM($pm) { if($pm >= 350.5) return scale($pm, 500, 401, 500, 350.5); if($pm >= 250.5) return scale($pm, 400, 301, 350.4, 250.5); if($pm >= 150.5) return scale($pm, 300, 201, 250.4, 150.5); if($pm >= 55.5) return scale($pm, 200, 151, 150.4, 55.5); if($pm >= 35.5) return scale($pm, 150, 101, 55.4, 35.5); if($pm >= 12.1) return scale($pm, 100, 51, 35.4, 12.1); if($pm >= 0) return scale($pm, 50, 0, 12, 0); return ''; } function scale($pm, $aqiHigh, $aqiLow, $pmHigh, $pmLow) { $a = $aqiHigh - $aqiLow; $b = $pmHigh - $pmLow; $c = $pm - $pmLow; }
WeChat ID
aaronpk_tv