3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = Array ( "states" => Array ( "" => "Select State", "1" => "Andaman and Nicobar (AN)", "2" => "Andhra Pradesh (AP)")); echo "<pre>"; print_r($array ); end($array['states']); // move the pointer to the end of the array $key = key($array['states']); // get the last key $value = $array['states'][$key]; //// get last value be key echo 'Last key '.$key.'and last value '. $value ; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4NIEG
function name:  (null)
number of ops:  22
compiled vars:  !0 = $array, !1 = $key, !2 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
    5     1        ECHO                                                         '%3Cpre%3E'
    6     2        INIT_FCALL                                                   'print_r'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                                     
    8     5        INIT_FCALL                                                   'end'
          6        FETCH_DIM_W                                          $5      !0, 'states'
          7        SEND_REF                                                     $5
          8        DO_ICALL                                                     
    9     9        INIT_FCALL                                                   'key'
         10        FETCH_DIM_R                                          ~7      !0, 'states'
         11        SEND_VAL                                                     ~7
         12        DO_ICALL                                             $8      
         13        ASSIGN                                                       !1, $8
   10    14        FETCH_DIM_R                                          ~10     !0, 'states'
         15        FETCH_DIM_R                                          ~11     ~10, !1
         16        ASSIGN                                                       !2, ~11
   12    17        CONCAT                                               ~13     'Last+key+', !1
         18        CONCAT                                               ~14     ~13, 'and+last+value+'
         19        CONCAT                                               ~15     ~14, !2
         20        ECHO                                                         ~15
   13    21      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
227.29 ms | 2130 KiB | 16 Q