<?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));
时间: 2024-09-29 08:23:52