php循环简写

mac2022-06-30  96

<?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));

 

转载于:https://www.cnblogs.com/hgj123/p/4653647.html

最新回复(0)