php - Get second to last value in array -


I am using the following to get the last value from one array to another:

  $ z = array_pop (array_slice ($ array, -2.1));  

Am I getting a php function to do this at once or is it best?

  end ($ array); $ Z = Previous ($ array);  

This is more efficient than your solution because it depends on the internal indicator of the array. Your solution makes an essential copy of the array.


Comments