Q:

Write a PHP program to get the head of a given list

0

Write a PHP program to get the head of a given list.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
function head($items)
{
    return reset($items);
}
print_r(head([1, 2, 3]));
echo "\n";
print_r(head([2, 1, 3, -4, 5, 1, 2]));

?>

Sample Output:

1
2

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now