base_url . '/api/v1/ticker/24hr'; $res = $curl->get($api, false); $ticker = []; if (is_array($res)) { $this->code = 0; foreach ($res as $val) { foreach ($this->basic_coin as $k => $coin) { $explode_arr = explode($coin, $val['symbol']); if (2 == count($explode_arr) && empty($explode_arr[1])) { $temp = []; $temp['symbol'] = $explode_arr[0] . '/' . $coin; $temp['currency'] = strtoupper($explode_arr[0]); $temp['base_currency'] = strtoupper($coin); $temp['close'] = (float)sprintf("%0.4f", $val['lastPrice']); $temp['close_rmb'] = (float)sprintf("%0.4f", $val['lastPrice'] * $this->basic_price[$coin]); $temp['change'] = (float)sprintf("%0.4f", $val['priceChangePercent']); $temp['high'] = (float)sprintf("%0.4f", $val['highPrice']); $temp['low'] = (float)sprintf("%0.4f", $val['lowPrice']); $temp['vol'] = (float)sprintf("%0.4f", $val['volume']); array_push($ticker, $temp); break; } } } } return ['code' => $this->code, 'ticker' => $ticker]; } }