3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array('first'=>'111', 'second'=>'222', 'third'=>'333'); // get the first key: returns 'first' print array_shift(array_keys($array)); // get the last key: returns 'third' print array_pop(array_keys($array)); // get the first value: returns '111' print array_shift(array_values($array)); // get the last value: returns '333' print array_pop(array_values($array));
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.32, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Notice: Only variables should be passed by reference in /in/PZDq1 on line 6 first Notice: Only variables should be passed by reference in /in/PZDq1 on line 9 third Notice: Only variables should be passed by reference in /in/PZDq1 on line 12 111 Notice: Only variables should be passed by reference in /in/PZDq1 on line 15 333
Output for 7.3.32 - 7.3.33
firstthird111333
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Strict Standards: Only variables should be passed by reference in /in/PZDq1 on line 6 first Strict Standards: Only variables should be passed by reference in /in/PZDq1 on line 9 third Strict Standards: Only variables should be passed by reference in /in/PZDq1 on line 12 111 Strict Standards: Only variables should be passed by reference in /in/PZDq1 on line 15 333

preferences:
246.85 ms | 403 KiB | 366 Q