3v4l.org

run code in 500+ PHP versions simultaneously
<?php // define arrays with the same keys - different key order ('4' and '@' are swapped) $array_at = [ '_' => '', 'Y' => '', '0' => '', '+' => '', 'X' => '', 'W' => '', '1' => '', '3' => '', '@' => '', '4' => '', '5' => '', 'P' => '', 'O' => '', 'N' => '', 'M' => '', 'L' => '', 'K' => '', ]; $array_fr = [ '_' => '', 'Y' => '', '0' => '', '+' => '', 'X' => '', 'W' => '', '1' => '', '3' => '', '4' => '', '@' => '', '5' => '', 'P' => '', 'O' => '', 'N' => '', 'M' => '', 'L' => '', 'K' => '', ]; ksort($array_at, SORT_STRING); // sort by key ksort($array_fr, SORT_STRING); // sort by key // expects the same key at the sorted array first position var_dump(array_slice($array_at, 0, 1)); // result: [0 => '''], but only '0' is defined as a key var_dump(array_slice($array_fr, 0, 1)); // result: ['+' => '' ]
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D84lS
function name:  (null)
number of ops:  27
compiled vars:  !0 = $array_at, !1 = $array_fr
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                       !0, <array>
    7     1        ASSIGN                                                       !1, <array>
   11     2        INIT_FCALL                                                   'ksort'
          3        SEND_REF                                                     !0
          4        SEND_VAL                                                     2
          5        DO_ICALL                                                     
   12     6        INIT_FCALL                                                   'ksort'
          7        SEND_REF                                                     !1
          8        SEND_VAL                                                     2
          9        DO_ICALL                                                     
   15    10        INIT_FCALL                                                   'var_dump'
         11        INIT_FCALL                                                   'array_slice'
         12        SEND_VAR                                                     !0
         13        SEND_VAL                                                     0
         14        SEND_VAL                                                     1
         15        DO_ICALL                                             $6      
         16        SEND_VAR                                                     $6
         17        DO_ICALL                                                     
   16    18        INIT_FCALL                                                   'var_dump'
         19        INIT_FCALL                                                   'array_slice'
         20        SEND_VAR                                                     !1
         21        SEND_VAL                                                     0
         22        SEND_VAL                                                     1
         23        DO_ICALL                                             $8      
         24        SEND_VAR                                                     $8
         25        DO_ICALL                                                     
         26      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.39 ms | 2010 KiB | 16 Q