php 循环简写

<?php


class a{
        public function news($news){
        $articles = array();
        foreach ($news as $key => $value) {
            list(
                $articles[$key]['Title'],
                $articles[$key]['Description'],
                $articles[$key]['Url'],
                $articles[$key]['PicUrl']
            ) = $value;

            if($key >= 9) break; //最多只允许10条图文信息
        }
        $data['ArticleCount'] = count($articles);
        $data['Articles']     = $articles;

        return $data;
    }
    
}
$arr=array(
   0=>array("Title","Description","Url","PicUrl")
);
$a=new a();
var_dump($a->news($arr));

 

posted @ 2015-07-17 10:18  麦田守望者~  阅读(211)  评论(0编辑  收藏  举报