P粉4474950692023-09-02 12:10:35
You need to create an extra class called Site and return an array of objects.
class Site { private int $siteId; private string $name; private string $bone; /** * @param int $siteId * @param string $name * @param string $bone */ public function __construct(int $siteId, string $name, string $bone) { $this->siteId = $siteId; $this->name = $name; $this->bone = $bone; } /** * @return int */ public function getSiteId(): int { return $this->siteId; } /** * @param int $siteId */ public function setSiteId(int $siteId): void { $this->siteId = $siteId; } /** * @return string */ public function getName(): string { return $this->name; } /** * @param string $name */ public function setName(string $name): void { $this->name = $name; } /** * @return string */ public function getBone(): string { return $this->bone; } /** * @param string $bone */ public function setBone(string $bone): void { $this->bone = $bone; } }
Then return the site array:
return [ (new Site(1, '开罗', 'T-Rex骨骼')), (new Site(2, '吉萨', '迅猛龙骨骼')), (new Site(3, '亚历山大', '腕龙骨骼')) ];