First Item Remove From Array In Php

Hello,

Immediately, i we are going to present you first merchandise take away from array in php. This text offers you easy instance of first merchandise take away from array in php. you’ll study first merchandise take away from array in php. So let’s comply with few step to create instance of first merchandise take away from array in php.

PHP array_shift() perform to take away the primary first merchandise from array. array_shift() will helps to take away first key from php array.

Instance 1:

index.php


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

Output:


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

Instance 2:

index.php


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

Output:


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

This instance will make it easier to…..

Komentar

Postingan populer dari blog ini

PHP 8 Multiple Select Dropdown Example

Laravel 8 Get HTTP Hostname

JQuery Drag And Drop Menu Example