3v4l.org

run code in 300+ PHP versions simultaneously
<?php function _rsort(&$data, $mode) { rsort($data, $mode); return $data; } $data = [1,5,19,3,67,8,9,45,6,2,18,24,58,63,12,10]; $result = array_filter( array: $data, callback: fn($item) => !in_array($item, array_slice(_rsort($data, SORT_NUMERIC), 0, 10)) ); print_r($result); $data = [1,5,19,3,67,8,9,45,6,2,18,24,58,63,12,10]; $top_10 = array_slice(_rsort($data, SORT_NUMERIC), 0, 10); $result = array_filter( array: $data, callback: fn($item) => !in_array($item, $top_10) ); print_r($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9Nieo
function name:  (null)
number of ops:  33
compiled vars:  !0 = $data, !1 = $result, !2 = $top_10
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, <array>
    7     1        INIT_FCALL                                               'array_filter'
    8     2        SEND_VAR                                                 !0
    9     3        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          4        BIND_LEXICAL                                             ~4, !0
   10     5        SEND_VAL                                                 ~4
    7     6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !1, $5
   11     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   13    11        ASSIGN                                                   !0, <array>
   15    12        INIT_FCALL                                               'array_slice'
         13        INIT_FCALL                                               '_rsort'
         14        SEND_REF                                                 !0
         15        SEND_VAL                                                 1
         16        DO_FCALL                                      0  $9      
         17        SEND_VAR                                                 $9
         18        SEND_VAL                                                 0
         19        SEND_VAL                                                 10
         20        DO_ICALL                                         $10     
         21        ASSIGN                                                   !2, $10
   16    22        INIT_FCALL                                               'array_filter'
   17    23        SEND_VAR                                                 !0
   18    24        DECLARE_LAMBDA_FUNCTION                          ~12     [1]
         25        BIND_LEXICAL                                             ~12, !2
   19    26        SEND_VAL                                                 ~12
   16    27        DO_ICALL                                         $13     
         28        ASSIGN                                                   !1, $13
   20    29        INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                                 
         32      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9Nieo
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $item, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'in_array'
          3        SEND_VAR                                                 !0
          4        INIT_FCALL                                               'array_slice'
          5        INIT_FCALL                                               '_rsort'
          6        SEND_REF                                                 !1
          7        SEND_VAL                                                 1
          8        DO_FCALL                                      0  $2      
          9        SEND_VAR                                                 $2
         10        SEND_VAL                                                 0
         11        SEND_VAL                                                 10
         12        DO_ICALL                                         $3      
         13        SEND_VAR                                                 $3
         14        DO_ICALL                                         $4      
         15        BOOL_NOT                                         ~5      $4
         16      > RETURN                                                   ~5
   10    17*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9Nieo
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $item, !1 = $top_10
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'in_array'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6        BOOL_NOT                                         ~3      $2
          7      > RETURN                                                   ~3
   19     8*     > RETURN                                                   null

End of Dynamic Function 1

Function _rsort:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9Nieo
function name:  _rsort
number of ops:  8
compiled vars:  !0 = $data, !1 = $mode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        INIT_FCALL                                               'rsort'
          3        SEND_REF                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                                 
          6      > RETURN                                                   !0
          7*     > RETURN                                                   null

End of function _rsort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.86 ms | 1009 KiB | 20 Q