Source Code:
(back to article)
<?php // Define an array with some values $array = ["apple", "banana", "cherry", "date", "elderberry", "fig", "grape", "honeydew", "indigo", "jackfruit", "kiwi", "lemon"]; // Loop through the first 10 items of the array and output their values foreach (array_slice($array, 0, 4) as $item) { echo $item . "\n"; } // Output: apple // banana // cherry // date
Result:
Report an issue