select('sid')->asArray()->all(),'sid'); foreach($sidItems as $sid){ if($sid){ $coinInfo = Coin::find()->where(['sid' => $sid])->one(); $release = $this->getReleaseTime($sid); $isDate = $this->isDateTime($release); if(!$isDate){ $release = ''; } $coinInfo->release = $release; $coinInfo->save(); echo '币种名称: '.$coinInfo->name.'--'.$coinInfo->nickname.'--sid: '.$sid.PHP_EOL; echo '发行时间: '.$release.' 更新成功'.PHP_EOL; } } } //更新上架交易所 public function actionCoinExchanges() { $sidItems = array_column(Coin::find()->select('sid')->asArray()->all(),'sid'); foreach($sidItems as $sid){ if($sid){ $coinInfo = Coin::find()->where(['sid' => $sid])->one(); $exchange = $this->getExchange($sid); $coinInfo->exchange = $exchange; $coinInfo->save(); echo '币种名称: '.$coinInfo->name.'--'.$coinInfo->nickname.'--sid: '.$sid.PHP_EOL; echo '上架交易所数量: '.$exchange.' 更新成功'.PHP_EOL; } } } private function getReleaseTime($sid) { try{ $feixiaohao_url = "https://www.feixiaohao.com/currencies/".$sid; $content = file_get_contents($feixiaohao_url); //preg_match 只匹配一次就返回 $patt = "/