phpサイクル略記
2856 ワード
<?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));