$item) { $tempItem = substr($item, stripos($item, "=\"") + 2); //获取 var hq_str_sz000002="万 科A,30.780,30.800,30.510, ="之后部分 $tempItem = substr($tempItem, 0, strripos($tempItem, "\"")); //获取 万 科A,30.94,0.14,0.45,584039,178827"; ";之前部分 $tempItem = trim($tempItem); if (!empty($tempItem)) { $arr2[$index] = explode(",", $tempItem);//分割 $arr2[$index]['code'] = $codeList[$codeIndex]; $index++; } $codeIndex++; } return $arr2; } //深市返回的成交量以个为单位,需转换为以手为单位 static private function getAmountForIndexDayK($code, $amount) { $newAmount = $amount; $index = Index::getInfoByCode($code); if ($index['exchange'] == STOCK_EXCHANGE_SZ) { $newAmount = round($amount / 100); } return $newAmount; } //获取index_day_k static public function getIndexDayK($indexList) { $codeList = array(); $codeIndex = 0; $url = self::GLOBAL_URL; foreach ($indexList as $item) { $codeStr = sprintf('%06s', $item['code']); $url .= $item['exchange'].$codeStr.','; $codeList[$codeIndex] = $codeStr; $codeIndex++; } $contentList = self::curl_get_data($url, $codeList); foreach ($contentList as $key => $item) { $data['code'] = $item['code']; $data['date'] = ConverseDate($item[30]); $data['name'] = trim($item[0]); $data['increase_price'] = floatval($item[3] - $item[2]); //涨跌价 $data['timestamp'] = strtotime($item[30]); //当天的0点时间戳 $data['open_price'] = floatval($item[1]); //开盘价 $data['close_price'] = floatval($item[3]); //当前价,15点之后就是收盘价 $data['highest_price'] = floatval($item[4]); //最高价 $data['lowest_price'] = floatval($item[5]); //最低价 $data['amount'] = self::getAmountForIndexDayK($data['code'], (int)($item[8])); //成交量,以手为单位 $data['value'] = (int)($item[9]); //成交金额,以万为单位 $data['increase_ratio'] = 0; //涨跌幅 if (!empty($data['open_price'])) $data['increase_ratio'] = round($data['increase_price'] * 100 / $data['open_price'], 2); if (!empty($item[0])) { //判断非法股票代码 Index_day_k::addOrUpdateByCodeDate($data); } } return; } } ?>