3v4l.org

run code in 300+ PHP versions simultaneously
<?php $users = array( "name one"=>"-11", "name two"=>"5.5", "name three"=>"8", "name four"=>"7", "name five"=>"9", "name six"=>"12"); asort($users); $keys = array_keys($users); if(end($users) + $users[$keys[0]] < $users[$keys[1]]-$users[$keys[0]]){ $new[0][$keys[0]] = array_splice($users,0,1); $new[0][end($keys)] = array_splice($users,-1); } $new = array_merge($new, array_chunk($users,2,true)); var_dump($new);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 40
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/739TZ
function name:  (null)
number of ops:  54
compiled vars:  !0 = $users, !1 = $keys, !2 = $new
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        INIT_FCALL                                               'asort'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
   12     4        INIT_FCALL                                               'array_keys'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !1, $5
   14     8        INIT_FCALL                                               'end'
          9        SEND_REF                                                 !0
         10        DO_ICALL                                         $7      
         11        FETCH_DIM_R                                      ~8      !1, 0
         12        FETCH_DIM_R                                      ~9      !0, ~8
         13        ADD                                              ~10     $7, ~9
         14        FETCH_DIM_R                                      ~11     !1, 1
         15        FETCH_DIM_R                                      ~12     !0, ~11
         16        FETCH_DIM_R                                      ~13     !1, 0
         17        FETCH_DIM_R                                      ~14     !0, ~13
         18        SUB                                              ~15     ~12, ~14
         19        IS_SMALLER                                               ~10, ~15
         20      > JMPZ                                                     ~16, ->40
   15    21    >   FETCH_DIM_R                                      ~18     !1, 0
         22        INIT_FCALL                                               'array_splice'
         23        SEND_REF                                                 !0
         24        SEND_VAL                                                 0
         25        SEND_VAL                                                 1
         26        DO_ICALL                                         $20     
         27        FETCH_DIM_W                                      $17     !2, 0
         28        ASSIGN_DIM                                               $17, ~18
         29        OP_DATA                                                  $20
   16    30        INIT_FCALL                                               'end'
         31        SEND_REF                                                 !1
         32        DO_ICALL                                         $22     
         33        INIT_FCALL                                               'array_splice'
         34        SEND_REF                                                 !0
         35        SEND_VAL                                                 -1
         36        DO_ICALL                                         $24     
         37        FETCH_DIM_W                                      $21     !2, 0
         38        ASSIGN_DIM                                               $21, $22
         39        OP_DATA                                                  $24
   20    40    >   INIT_FCALL                                               'array_merge'
         41        SEND_VAR                                                 !2
         42        INIT_FCALL                                               'array_chunk'
         43        SEND_VAR                                                 !0
         44        SEND_VAL                                                 2
         45        SEND_VAL                                                 <true>
         46        DO_ICALL                                         $25     
         47        SEND_VAR                                                 $25
         48        DO_ICALL                                         $26     
         49        ASSIGN                                                   !2, $26
   23    50        INIT_FCALL                                               'var_dump'
         51        SEND_VAR                                                 !2
         52        DO_ICALL                                                 
         53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.39 ms | 1009 KiB | 20 Q