PHP : Remove the first value from an array

In this tutorial learn  Remove the first value from an array in php.

function removeFirstelement($array)
  {
        array_shift($array);

        return $array;
  }



TUTORIAL


<?php

$array = Array
(
    '3' => 10,
    '2' => 2,
    '5' => 'Nakiya',

);
      
      
    /**
     * Remove the first value from an array.
     */
    function removeFirstelement($array)
    {
        array_shift($array);

        return $array;
    }

var_dump(removeFirstelement($array));
OUTPUT DEMO

array(2) {
  [0]=>
  int(2)
  [1]=>
  string(6) "Nakiya"
}

No comments:

Post a Comment