// 小学特色 $feature = ''; if ($school['pfeature']) { $feature = implode(';', array_map(array($this, 'mapFeature'), explode(',', $school['pfeature']))); } // 周边幼儿园 $kindergarten = ''; if (!empty($kinders[$id])) { $kindergarten = implode(';', $kinders[$id]); } // 对口中学 $pmschool = array(); if (!empty($middles[$id])) { $pmschool = $middles[$id]; } $result[] = array('key' => $newNames[$id][1] . '+' . $newNames[$id][0], 'display' => array('pschoolId' => $newNames[$id][0], 'settleyear' => $school['settleyear'], 'settlequota' => self::$QUOTA[$school['settlequota'] ? $school['settlequota'] : -1], 'paddress' => $school['paddress'], 'ptele' => $school['ptele'], 'pfeature' => $feature, 'pkindergarten' => $kindergarten), 'pschoolName' => $newNames[$id][1], 'pschooltype' => self::$TYPE[$school['pschooltypeid']], 'pmschool' => $pmschool, 'alltype' => '市重点;区重点;普通', 'pschooltypeid' => self::$TYPEID[$school['pschooltypeid']]); } return $result; } public function writSchoolXml() { $data = self::assembleArray(); $xml = self::arrToXml($data); self::writeXmlToFile('newxml.xml', $xml); } } // header ( "Content-Type: text/html; charset=utf-8" ); header('Content-type: application/json; charset=utf-8'); $sougou = new Sogou(); $sougou->writSchoolXml();