3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sortByDefault(array $domains, $default='com') { $GLOBALS['defaulttld'] = $default; if (!function_exists('tldsort')) { function tldsort($a, $b) { $default = $GLOBALS['defaulttld']; if ($a['tld'] == $default) { return -1; } elseif ($b['tld'] == $default) { return 1; } elseif ($a['tld'] == 'net') { return -1; } elseif ($b['tld'] == 'net') { return 1; } elseif ($a['tld'] == 'org') { return -1; } elseif ($b['tld'] == 'org') { return 1; } elseif ($a['tld'] == 'us') { return -1; } elseif ($b['tld'] == 'us') { return 1; } elseif ($a['tld'] == 'biz') { return -1; } elseif ($b['tld'] == 'biz') { return 1; } elseif ($a['tld'] == 'info') { return -1; } elseif ($b['tld'] == 'info') { return 1; } else { return strcmp($a['tld'], $b['tld']); } } } uasort($domains, 'tldsort'); return $domains; } $domains = array('google.com', 'google.net', 'google.org', 'google.us', 'google.biz', 'google.info'); sortByDefault($domains, 'biz');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RiStS
function name:  (null)
number of ops:  6
compiled vars:  !0 = $domains
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   ASSIGN                                                   !0, <array>
   43     1        INIT_FCALL                                               'sortbydefault'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'biz'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Function sortbydefault:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/RiStS
function name:  sortByDefault
number of ops:  17
compiled vars:  !0 = $domains, !1 = $default
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'com'
    3     2        FETCH_W                      global              $2      'GLOBALS'
          3        ASSIGN_DIM                                               $2, 'defaulttld'
          4        OP_DATA                                                  !1
    4     5        INIT_FCALL                                               'function_exists'
          6        SEND_VAL                                                 'tldsort'
          7        DO_ICALL                                         $4      
          8        BOOL_NOT                                         ~5      $4
          9      > JMPZ                                                     ~5, ->11
    5    10    >   DECLARE_FUNCTION                                         'tldsort'
   37    11    >   INIT_FCALL                                               'uasort'
         12        SEND_REF                                                 !0
         13        SEND_VAL                                                 'tldsort'
         14        DO_ICALL                                                 
   38    15      > RETURN                                                   !0
   39    16*     > RETURN                                                   null

End of function sortbydefault

Function %00tldsort%2Fin%2FRiStS%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 45
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 50
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 55
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 60
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 65
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RiStS
function name:  tldsort
number of ops:  73
compiled vars:  !0 = $a, !1 = $b, !2 = $default
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        FETCH_R                      global              ~3      'GLOBALS'
          3        FETCH_DIM_R                                      ~4      ~3, 'defaulttld'
          4        ASSIGN                                                   !2, ~4
    8     5        FETCH_DIM_R                                      ~6      !0, 'tld'
          6        IS_EQUAL                                                 !2, ~6
          7      > JMPZ                                                     ~7, ->10
    9     8    > > RETURN                                                   -1
          9*       JMP                                                      ->72
   10    10    >   FETCH_DIM_R                                      ~8      !1, 'tld'
         11        IS_EQUAL                                                 !2, ~8
         12      > JMPZ                                                     ~9, ->15
   11    13    > > RETURN                                                   1
         14*       JMP                                                      ->72
   12    15    >   FETCH_DIM_R                                      ~10     !0, 'tld'
         16        IS_EQUAL                                                 ~10, 'net'
         17      > JMPZ                                                     ~11, ->20
   13    18    > > RETURN                                                   -1
         19*       JMP                                                      ->72
   14    20    >   FETCH_DIM_R                                      ~12     !1, 'tld'
         21        IS_EQUAL                                                 ~12, 'net'
         22      > JMPZ                                                     ~13, ->25
   15    23    > > RETURN                                                   1
         24*       JMP                                                      ->72
   16    25    >   FETCH_DIM_R                                      ~14     !0, 'tld'
         26        IS_EQUAL                                                 ~14, 'org'
         27      > JMPZ                                                     ~15, ->30
   17    28    > > RETURN                                                   -1
         29*       JMP                                                      ->72
   18    30    >   FETCH_DIM_R                                      ~16     !1, 'tld'
         31        IS_EQUAL                                                 ~16, 'org'
         32      > JMPZ                                                     ~17, ->35
   19    33    > > RETURN                                                   1
         34*       JMP                                                      ->72
   20    35    >   FETCH_DIM_R                                      ~18     !0, 'tld'
         36        IS_EQUAL                                                 ~18, 'us'
         37      > JMPZ                                                     ~19, ->40
   21    38    > > RETURN                                                   -1
         39*       JMP                                                      ->72
   22    40    >   FETCH_DIM_R                                      ~20     !1, 'tld'
         41        IS_EQUAL                                                 ~20, 'us'
         42      > JMPZ                                                     ~21, ->45
   23    43    > > RETURN                                                   1
         44*       JMP                                                      ->72
   24    45    >   FETCH_DIM_R                                      ~22     !0, 'tld'
         46        IS_EQUAL                                                 ~22, 'biz'
         47      > JMPZ                                                     ~23, ->50
   25    48    > > RETURN                                                   -1
         49*       JMP                                                      ->72
   26    50    >   FETCH_DIM_R                                      ~24     !1, 'tld'
         51        IS_EQUAL                                                 ~24, 'biz'
         52      > JMPZ                                                     ~25, ->55
   27    53    > > RETURN                                                   1
         54*       JMP                                                      ->72
   28    55    >   FETCH_DIM_R                                      ~26     !0, 'tld'
         56        IS_EQUAL                                                 ~26, 'info'
         57      > JMPZ                                                     ~27, ->60
   29    58    > > RETURN                                                   -1
         59*       JMP                                                      ->72
   30    60    >   FETCH_DIM_R                                      ~28     !1, 'tld'
         61        IS_EQUAL                                                 ~28, 'info'
         62      > JMPZ                                                     ~29, ->65
   31    63    > > RETURN                                                   1
         64*       JMP                                                      ->72
   33    65    >   INIT_FCALL                                               'strcmp'
         66        FETCH_DIM_R                                      ~30     !0, 'tld'
         67        SEND_VAL                                                 ~30
         68        FETCH_DIM_R                                      ~31     !1, 'tld'
         69        SEND_VAL                                                 ~31
         70        DO_ICALL                                         $32     
         71      > RETURN                                                   $32
   35    72*     > RETURN                                                   null

End of function %00tldsort%2Fin%2FRiStS%3A5%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.57 ms | 1407 KiB | 20 Q