PHP : Remove the last value from an array

In this tutorial learn how to remove the last value from an array in php.



function removeLastelement($array)
    {
        array_pop($array);

        return $array;
    }



TUTORIAL



<?php

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

);
      
      
    /**
     * Remove the last value from an array
     */
    function removeLastelement($array)
    {
        array_pop($array);

        return $array;
    }


var_dump(removeLastelement($array));
OUTPUT



array(2) {
  [3]=>
  int(10)
  [2]=>
  int(2)
}

No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...