Alex Rivera | Logout

How to skip the 1st key in an array loop?

Asked 2008-12-16T14:52:25.143
58

I have the following code:

if ($_POST['submit'] == "Next") {
    foreach($_POST['info'] as $key => $value) {
        echo $value;
    }
}

How do I get the foreach function to start from the 2nd key in the array?

Edit
Report

1 Answer

132

For reasonably small arrays, use array_slice to create a second one:

foreach(array_slice($_POST['info'],1) as $key=>$value)
{
    echo $value;
}
answered 2008-12-16T14:56:47.053

Your Answer