} if (!$ret && $atd['unitPrice'] && $btd['unitPrice']) { $ret = 1 * (int) 1000 * ($atd['unitPrice'] - $btd['unitPrice']); } if (!$ret) { $ret = (int) ($ap->getData()['price'] - $bp->getData()['price']); } if (!$ret) { $ret = strcmp($ap->getData()['name'], $bp->getData()['name']); } return $ret; }); foreach ($availableProducts as $rawProd) { $prod = new Product($rawProd['id'], $rawProd['spider']); $data = $prod->getData(); $history = $prod->getHistory(); foreach ($history as $k => $hist) { if ($hist['run_id'] == $data['run_id']) { unset($history[$k]); } } /* compute the class relative to the first item in history */ $trClass = array(); $fhist = reset($history); $sign = 0; $adiff = 0; if ($fhist) { if ($fhist['price'] > $data['price']) { $trClass[] = "price-lower"; $sign = -1; } elseif ($fhist['price'] < $data['price']) {