<?php $arr = [1,2,3,4];$ultimo = end($arr);var_dump($ultimo);var_dump($arr);$ultimo = array_splice($arr, -1, 1);var_dump($ultimo[0]);var_dump($arr);
Standard input is empty
int(4) array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) } int(4) array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) }
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!