Join WhatsApp ChannelJoin Now

First Item Remove From Array In Php

Hi,

Today, i we will show you first item remove from array in php. This article will give you simple example of first item remove from array in php. you will learn first item remove from array in php. So let’s follow few step to create example of first item remove from array in php.

PHP array_shift() function to remove the first first item from array. array_shift() will helps to remove first key from php array.

Example 1:

index.php

<?php
    $myArray = ["Apple", "Banana", "Mango"];
    array_shift($myArray);
    print_r($myArray);
?>

Output:

Array
(
    [0] => Banana
    [1] => Mango
)

Example 2:

index.php

<?php
    $students = [
        [ "id" => 1, "name" => "Rakesh"],
        [ "id" => 2, "name" => "Mohan"],
        [ "id" => 3, "name" => "Rahul"],
    ];
    array_shift($students);
    print_r($students);
?>

Output:

Array
(
    [0] => Array
        (
            [id] => 2
            [name] => Mohan
        )
    [1] => Array
        (
            [id] => 3
            [name] => Rahul
        )
)

This example will help you…..

Recommended Posts