3v4l.org

run code in 300+ PHP versions simultaneously
<?php $multi_dim = array( array('id' => 1, 'title' => 'Tv', 'cat' => 1, 'value' => 100), array('id' => 2, 'title' => 'Laptop', 'cat' => 1, 'value' => 200), array('id' => 3, 'title' => 'Phone', 'cat' => 1, 'value' => 100), array('id' => 4, 'title' => 'Painting', 'cat' => 2, 'value' => 100), ); $call_back = function( $a ){ if ( $a['cat'] == 1 && $a['value'] == 100 ){ return $a; } }; $callback = function ($a,$b) { if ( $a['cat'] >= $b['cat'] && $a['value'] >= $b['value'] ){ return true; } }; usort( $multi_dim,$callback ); $max = 1; $rand = mt_rand( 0, $max ); $slice = array_slice($multi_dim,0,2); var_dump($slice);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7EFMY
function name:  (null)
number of ops:  25
compiled vars:  !0 = $multi_dim, !1 = $call_back, !2 = $callback, !3 = $max, !4 = $rand, !5 = $slice
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    8     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7EFMY%3A8%240'
          2        ASSIGN                                                   !1, ~7
   13     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7EFMY%3A13%241'
          4        ASSIGN                                                   !2, ~9
   20     5        INIT_FCALL                                               'usort'
          6        SEND_REF                                                 !0
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                                 
   21     9        ASSIGN                                                   !3, 1
   22    10        INIT_FCALL                                               'mt_rand'
         11        SEND_VAL                                                 0
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                         $13     
         14        ASSIGN                                                   !4, $13
   23    15        INIT_FCALL                                               'array_slice'
         16        SEND_VAR                                                 !0
         17        SEND_VAL                                                 0
         18        SEND_VAL                                                 2
         19        DO_ICALL                                         $15     
         20        ASSIGN                                                   !5, $15
   24    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !5
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F7EFMY%3A8%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/7EFMY
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        FETCH_DIM_R                                      ~1      !0, 'cat'
          2        IS_EQUAL                                         ~2      ~1, 1
          3      > JMPZ_EX                                          ~2      ~2, ->7
          4    >   FETCH_DIM_R                                      ~3      !0, 'value'
          5        IS_EQUAL                                         ~4      ~3, 100
          6        BOOL                                             ~2      ~4
          7    > > JMPZ                                                     ~2, ->9
   10     8    > > RETURN                                                   !0
   12     9    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7EFMY%3A8%240

Function %00%7Bclosure%7D%2Fin%2F7EFMY%3A13%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/7EFMY
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        FETCH_DIM_R                                      ~2      !0, 'cat'
          3        FETCH_DIM_R                                      ~3      !1, 'cat'
          4        IS_SMALLER_OR_EQUAL                              ~4      ~3, ~2
          5      > JMPZ_EX                                          ~4      ~4, ->10
          6    >   FETCH_DIM_R                                      ~5      !0, 'value'
          7        FETCH_DIM_R                                      ~6      !1, 'value'
          8        IS_SMALLER_OR_EQUAL                              ~7      ~6, ~5
          9        BOOL                                             ~4      ~7
         10    > > JMPZ                                                     ~4, ->12
   15    11    > > RETURN                                                   <true>
   17    12    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7EFMY%3A13%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.66 ms | 1400 KiB | 21 Q