salman_ahad@yahoo.com Posted December 8, 2009 Share Posted December 8, 2009 PHP function that would return the next to last key (not value) in an array when an array is provided as a parameter. If there are not two or more elements in the array, the function should return false. What will be the PHP script for this? Quote Link to comment Share on other sites More sharing options...
abazoskib Posted December 8, 2009 Share Posted December 8, 2009 PHP function that would return the next to last key (not value) in an array when an array is provided as a parameter. If there are not two or more elements in the array, the function should return false. What will be the PHP script for this? function nexttolast($array) { $size = count($array); if($size < 2) return false; else { return array_keys($array,$array[$size-2]); } } print_r(nexttolast($array)); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.