You only want to display eight of them. Do not want to display all. Please help write it completely. Thank you & lt ;? Phpif ($ history) {foreach ($ historyas $ val) {echo & quot; & lt; ahref? Id $ val [0] & gt; & quot ;. $ val [3]. & quot; & lt; a & gt; & lt; br & gt; & quot only want to display eight of them. Do not want to display all. Please write it completely. thank you.
Foreach ($ history as $ val ){
Echo "". $ val [3]."
";
}
} Else {
Echo"
No record
";
}
?>
------ Solution --------------------
Foreach (array_slice ($ history, 0, 8) as $ val)
------ Solution --------------------
If ($ history ){
Foreach (array_slice ($ history, 0, 8) as $ val ){
Echo "". $ val [3]."
";
}
} Else {
Echo"
No record
";
}
------ Solution --------------------
Discussion
Reference:
Foreach (array_slice ($ history, 0, 8) as $ val)
Can I display the latest 8 data records?