3v4l.org

run code in 300+ PHP versions simultaneously
<?php function odd ( $var ) { // returns whether the input integer is odd return( $var & 1 ); } function even ( $var ) { // returns whether the input integer is even return(!( $var & 1 )); } $array1 = array( "a" => 1 , "b" => 2 , "c" => 3 , "d" => 4 , "e" => 5 ); $array2 = array( 6 , 7 , 8 , 9 , 10 , 11 , 12 ); echo "Odd :\n" ; print_r ( array_filter ( $array1 , "odd" )); echo "Even:\n" ; print_r ( array_filter ( $array2 , "even" )); $input = array( "Neo" , "Morpheus" , "Trinity" , "Cypher" , "Tank" ); $rand_keys = array_rand ( $input , 2 ); echo $input [ $rand_keys [ 0 ]] . "\n" ; echo $input [ $rand_keys [ 1 ]] . "\n" ; $arr=['a'=>4,6,3];var_dump($arr); function cmp ( $a , $b ) { return strcmp ( $a [ "fruit" ], $b [ "fruit" ]); } $fruits [ 0 ][ "fruit" ] = "lemons" ; $fruits [ 1 ][ "fruit" ] = "apples" ; $fruits [ 2 ][ "fruit" ] = "grapes" ; print_r($fruits); usort ( $fruits , "cmp" ); while (list( $key , $value ) = each ( $fruits )) { echo " $fruits [ $key ] : " . $value [ "fruit" ] . "\n" ; } $a = array( 3 , 2 , 5 , 6 , 1 ); usort ( $a , "cmp" ); foreach ( $a as $key => $value ) { echo " $key : $value \n" ; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 53
Branch analysis from position: 70
2 jumps found. (Code = 77) Position 1 = 76, Position 2 = 85
Branch analysis from position: 76
2 jumps found. (Code = 78) Position 1 = 77, Position 2 = 85
Branch analysis from position: 77
1 jumps found. (Code = 42) Position 1 = 76
Branch analysis from position: 76
Branch analysis from position: 85
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 85
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 53
Branch analysis from position: 70
Branch analysis from position: 53
filename:       /in/fuUrg
function name:  (null)
number of ops:  87
compiled vars:  !0 = $array1, !1 = $array2, !2 = $input, !3 = $rand_keys, !4 = $arr, !5 = $fruits, !6 = $key, !7 = $value, !8 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   16     1        ASSIGN                                                   !1, <array>
   18     2        ECHO                                                     'Odd+%3A%0A'
   19     3        INIT_FCALL                                               'print_r'
          4        INIT_FCALL                                               'array_filter'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 'odd'
          7        DO_ICALL                                         $11     
          8        SEND_VAR                                                 $11
          9        DO_ICALL                                                 
   20    10        ECHO                                                     'Even%3A%0A'
   21    11        INIT_FCALL                                               'print_r'
         12        INIT_FCALL                                               'array_filter'
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 'even'
         15        DO_ICALL                                         $13     
         16        SEND_VAR                                                 $13
         17        DO_ICALL                                                 
   24    18        ASSIGN                                                   !2, <array>
   25    19        INIT_FCALL                                               'array_rand'
         20        SEND_VAR                                                 !2
         21        SEND_VAL                                                 2
         22        DO_ICALL                                         $16     
         23        ASSIGN                                                   !3, $16
   26    24        FETCH_DIM_R                                      ~18     !3, 0
         25        FETCH_DIM_R                                      ~19     !2, ~18
         26        CONCAT                                           ~20     ~19, '%0A'
         27        ECHO                                                     ~20
   27    28        FETCH_DIM_R                                      ~21     !3, 1
         29        FETCH_DIM_R                                      ~22     !2, ~21
         30        CONCAT                                           ~23     ~22, '%0A'
         31        ECHO                                                     ~23
   28    32        ASSIGN                                                   !4, <array>
         33        INIT_FCALL                                               'var_dump'
         34        SEND_VAR                                                 !4
         35        DO_ICALL                                                 
   35    36        FETCH_DIM_W                                      $26     !5, 0
         37        ASSIGN_DIM                                               $26, 'fruit'
         38        OP_DATA                                                  'lemons'
   36    39        FETCH_DIM_W                                      $28     !5, 1
         40        ASSIGN_DIM                                               $28, 'fruit'
         41        OP_DATA                                                  'apples'
   37    42        FETCH_DIM_W                                      $30     !5, 2
         43        ASSIGN_DIM                                               $30, 'fruit'
         44        OP_DATA                                                  'grapes'
   38    45        INIT_FCALL                                               'print_r'
         46        SEND_VAR                                                 !5
         47        DO_ICALL                                                 
   39    48        INIT_FCALL                                               'usort'
         49        SEND_REF                                                 !5
         50        SEND_VAL                                                 'cmp'
         51        DO_ICALL                                                 
   41    52      > JMP                                                      ->62
   42    53    >   ROPE_INIT                                     5  ~35     '+'
         54        ROPE_ADD                                      1  ~35     ~35, !5
         55        ROPE_ADD                                      2  ~35     ~35, '+%5B+'
         56        ROPE_ADD                                      3  ~35     ~35, !6
         57        ROPE_END                                      4  ~34     ~35, '+%5D+%3A+'
         58        FETCH_DIM_R                                      ~38     !7, 'fruit'
         59        CONCAT                                           ~39     ~34, ~38
         60        CONCAT                                           ~40     ~39, '%0A'
         61        ECHO                                                     ~40
   41    62    >   INIT_FCALL_BY_NAME                                       'each'
         63        SEND_VAR_EX                                              !5
         64        DO_FCALL                                      0  $41     
         65        FETCH_LIST_R                                     $42     $41, 0
         66        ASSIGN                                                   !6, $42
         67        FETCH_LIST_R                                     $44     $41, 1
         68        ASSIGN                                                   !7, $44
         69      > JMPNZ                                                    $41, ->53
   51    70    >   ASSIGN                                                   !8, <array>
   53    71        INIT_FCALL                                               'usort'
         72        SEND_REF                                                 !8
         73        SEND_VAL                                                 'cmp'
         74        DO_ICALL                                                 
   55    75      > FE_RESET_R                                       $48     !8, ->85
         76    > > FE_FETCH_R                                       ~49     $48, !7, ->85
         77    >   ASSIGN                                                   !6, ~49
   56    78        ROPE_INIT                                     5  ~52     '+'
         79        ROPE_ADD                                      1  ~52     ~52, !6
         80        ROPE_ADD                                      2  ~52     ~52, '+%3A++'
         81        ROPE_ADD                                      3  ~52     ~52, !7
         82        ROPE_END                                      4  ~51     ~52, '+%0A'
         83        ECHO                                                     ~51
   55    84      > JMP                                                      ->76
         85    >   FE_FREE                                                  $48
   57    86      > RETURN                                                   1

Function odd:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fuUrg
function name:  odd
number of ops:  4
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    6     1        BW_AND                                           ~1      !0, 1
          2      > RETURN                                                   ~1
    7     3*     > RETURN                                                   null

End of function odd

Function even:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fuUrg
function name:  even
number of ops:  5
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   12     1        BW_AND                                           ~1      !0, 1
          2        BOOL_NOT                                         ~2      ~1
          3      > RETURN                                                   ~2
   13     4*     > RETURN                                                   null

End of function even

Function cmp:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fuUrg
function name:  cmp
number of ops:  10
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   32     2        INIT_FCALL                                               'strcmp'
          3        FETCH_DIM_R                                      ~2      !0, 'fruit'
          4        SEND_VAL                                                 ~2
          5        FETCH_DIM_R                                      ~3      !1, 'fruit'
          6        SEND_VAL                                                 ~3
          7        DO_ICALL                                         $4      
          8      > RETURN                                                   $4
   33     9*     > RETURN                                                   null

End of function cmp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.21 ms | 1396 KiB | 25 Q