-2

code:

<?php foreach($posts as $post) {

echo $post['name'] 
};
?>

Result : 100 value I want to print 10 values only How that?

kadour Hk
  • 47
  • 4
  • 1
    100 values from database? If so, why you taking 100 result? Just limit to 10 result in query will fix your problem right? – Saji Mar 11 '19 at 11:39

1 Answers1

0

Try like this

foreach($posts as $key => $post) {
  echo $post['name']; 

  //It will execute only ten times
  if($key == 9){
     break;
  }
}
Danish Ali
  • 2,354
  • 3
  • 15
  • 26