prepare("SELECT `sid`, `name`, `alid`, `arid`, `hash` FROM `songs` WHERE `name` LIKE ? OR `sid`=?"); $keyword="%".$_GET['keyword']."%"; $sql->bind_param("si",$keyword,$_GET['keyword']); $sql->execute(); $sql->bind_result($sid,$name,$alid,$arid,$hash); while($sql->fetch()){ array_push($songs,array("sid"=>$sid,"name"=>$name,"alid"=>$alid,"arid"=>$arid,"hash"=>$hash)); } //理顺结果 foreach ($songs as $value){ $artistsFormat=array(); foreach (json_decode($value["arid"]) as $value2){ array_push($artistsFormat,getArtist($conn,$value2)); } $albumFormat=getAlbum($conn,$value["alid"]); array_push($result,array("id"=>$value["sid"],"name"=>$value["name"],"url"=>"https://cachev1.radio.fmhs.club/song/".$value["hash"],"hash"=>$value["hash"],"ar"=>$artistsFormat,"al"=>$albumFormat)); } $conn->close(); exit(json_encode(array("status"=>"success","message"=>"success","result"=>$result))); }else{ exit(json_encode(array("status"=>"failed","message"=>"need song info"))); }