How to remove first element from an array in php?

Member

brisa

by brisa , in category: PHP , a month ago

How to remove first element from an array in php?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by audrey.hodkiewicz , a month ago

@brisa I usually use array_shift function in PHP to remove first element from an array, here is my example:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<?php

$array = ['first', 'second', 'third'];

array_shift($array);

var_dump($array);

//array(2) {
//    [0]=>
//  string(6) "second"
//    [1]=>
//  string(5) "third"
//}