} } 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'])); } } exit(W::response($xml, $data, 'news')); break; case 15: $res = shejidaren(); $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'], 'cover' => $res[$i]['cover'], 'link' => $res[$i]['link'])); } } exit(W::response($xml, $data, 'news')); break; case 16: $res = ri91(); $data = array(array('title' => '网络安全攻防研究室', 'cover' => $web . '/img/91ri.gif')); 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 shejidaren() { $data = array(); $url = 'http://www.shejidaren.com/feed'; $result = file_get_contents($url); $xml = simplexml_load_string($result, 'SimpleXMLElement', LIBXML_NOCDATA); for ($i = 0; $i < 6; $i++) { $reg = '#<img src="(http://images\\.shejidaren\\.com/wp-content/uploads/.+)"[\\s]+class#i'; preg_match_all($reg, $xml->channel->item[$i]->description, $matches); array_push($data, array('title' => $xml->channel->item[$i]->title, 'cover' => $matches[1][0], 'link' => $xml->channel->item[$i]->link)); } return $data; } print_r(shejidaren());