标签: php codeigniter loops foreach
代码:
<?php foreach($posts as $post) { echo $post['name'] }; ?>
结果:100值 我只想打印10个值?
答案 0 :(得分:0)
尝试这样
foreach($posts as $key => $post) { echo $post['name']; //It will execute only ten times if($key == 9){ break; } }