$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; } //获取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'] = $item[30]; $data['increase_ratio'] = 0; //此接口中没有涨跌幅,设为0 $data['name'] = trim($item[0]); $data['increase_price'] = floatval($item[3] - $item[2]);//涨跌 $data['timestamp'] = 0;//当天的0点时间戳 $data['open_price'] = floatval($item[1]);//开盘价 $data['close_price'] = floatval($item[3]);//3点之后的当前价格就是收盘价 $data['highest_price'] = floatval($item[4]);//今日最高价 $data['lowest_price'] = floatval($item[5]);//今日最低价 $data['amount'] = (int)($item[8]);//成交的股票数,以百为单位 $data['value'] = (int)($item[9]);//成交金额以万为单位 if (!empty($item[0])) { //判断非法股票代码 Index_day_k::addOrUpdateByCodeDate($data); } } return; } } ?>