} } exit(W::response($xml, $data, 'news')); break; case 12: $res = matrix67(); $data = array(array('title' => 'matrix67', 'cover' => $web . '/img/matrix67.png')); for ($i = 0; $i < count($data); $i++) { if ($res[$i]) { array_push($data, array('title' => $res[$i]['title'], 'note' => $res[$i]['description'], 'link' => $res[$i]['link'])); } } exit(W::response($xml, $data, 'news')); break; case 13: $res = freebuf(); $data = array(array('title' => 'Freebuf', 'cover' => $web . '/img/freebuf.jpg')); for ($i = 0; $i < count($data); $i++) { if ($res[$i]) { array_push($data, array('title' => $res[$i]['title'], 'note' => $res[$i]['description'], 'link' => $res[$i]['link'])); } } exit(W::response($xml, $data, 'news')); break; case 14: $res = nginx(); $data = array(array('title' => '好的架构减少运维,好的运维反哺架构', 'cover' => $web . '/img/meizi/' . mt_rand(0, 9) . '.jpg')); for ($i = 0; $i < count($data); $i++) { if ($res[$i]) { array_push($data, array('title' => $res[$i]['title'], 'note' => $res[$i]['description'], 'link' => $res[$i]['link'])); }
<?php header('Content-type:text/html;charset=utf-8'); function freebuf() { $data = array(); $url = 'http://www.freebuf.com/feed'; $result = file_get_contents($url); $xml = simplexml_load_string($result, 'SimpleXMLElement', LIBXML_NOCDATA); for ($i = 0; $i < 6; $i++) { array_push($data, array('title' => $xml->channel->item[$i]->title, 'description' => htmlspecialchars_decode($xml->channel->item[$i]->description), 'link' => $xml->channel->item[$i]->link)); } return $data; } print_r(freebuf());