array_key_last(): to get the last key of an array

key = array_key_last ($input_array);
$input_arrayRequired : Input array for which last key is to be returned.
arrays_key_last() function returns the last key of the array. If the array is empty then NULL is returned.
PHP 7.3.0 Supported by PHP 7.3.0 and above

Example 1

echo array_key_last($input);
Output is here
Note that the first key is 0 , so the last key in above code is 4

Example 2

$input=array('One' =>'First','Two'=>'Second','Three'=>'Third','Fourth');
echo var_dump(array_key_last($input));
The output is here

Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here .

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer