Q:

Write a PHP program to return all elements in a given array except for the first one

0

Write a PHP program to return all elements in a given array except for the first one.

 

All Answers

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

<?php
//Licence: https://bit.ly/2CFA5XY

function tail($items)
{
    return count($items) > 1 ? array_slice($items, 1) : $items;
}
print_r(tail([1, 2, 3]));

?>

Sample Output:

Array
(
    [0] => 2
    [1] => 3
)

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