PHP : Get the last value from an array

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

function last($array)
    {
            return array_pop($array);
    }

TUTORIAL

<?php

$array = Array
(
    'user_id' => 10,
    'id' => 2,
    'user' => 'Nakiya',
);
  
/**
 * Get the last value from an array.
 */
function last($array)
    {
            return array_pop($array);
    }


var_dump(last($array));

OUTPUT : DEMO

string(6) "Nakiya"

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...