How can laravel foreach determine that only the first two lines are looped out.

foreach ($logo as $logo){
    echo "
    <a href="$logo->href"><img src="$logo->img"></a>
  ";
}
?>
Apr.21,2021

laravel collection there are many ready-made functions available, and the query result set is also in the form of a collection. It is recommended to switch to the collection processing. The above can be written as follows: collect ($logo)-> take (2);



$i=0;
foreach ($logo as $logo){
if($i==2){break;}
    echo "
    <a href='$logo->href'><img src='$logo->img'></a>
  ";
    $iPP;
}

the foundation is not firmly shaken. Take a look at the foundation


array_slice (xxx, 0,2) you can also cut
this $logo as $logo is very strong

.
Menu