[email protected] 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? Link to comment https://forums.phpfreaks.com/topic/184414-how-to-write-this-code/ 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)); Link to comment https://forums.phpfreaks.com/topic/184414-how-to-write-this-code/#findComment-973483 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.