3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sortByDefault(array &$domains, $default='com') { $sort = array($default, 'net', 'org', 'us', 'biz', 'info'); uasort($domains, function($a, $b) use ($sort) { foreach ($sort as $tld) { if ($a['tld'] === $tld) { return -1; } elseif ($b['tld'] === $tld) { return 1; } } return strcmp($a['tld'], $b['tld']); }); return $domains; } $domains = array('google.com', 'google.net', 'google.org', 'google.us', 'google.biz', 'google.info'); // Format these into arrays so that this shitty function works. $domains = array_map(function($d) { list($name, $tld) = explode('.', $d); return array('name' => $name, 'tld' => $tld); }, $domains); var_dump(sortByDefault($domains, 'biz'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SubHK
function name:  (null)
number of ops:  15
compiled vars:  !0 = $domains
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                   !0, <array>
   23     1        INIT_FCALL                                               'array_map'
          2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FSubHK%3A23%241'
   26     3        SEND_VAL                                                 ~2
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
   23     6        ASSIGN                                                   !0, $3
   28     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'sortbydefault'
          9        SEND_REF                                                 !0
         10        SEND_VAL                                                 'biz'
         11        DO_FCALL                                      0  $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function sortbydefault:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SubHK
function name:  sortByDefault
number of ops:  17
compiled vars:  !0 = $domains, !1 = $default, !2 = $sort
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'com'
    4     2        INIT_ARRAY                                       ~3      !1
          3        ADD_ARRAY_ELEMENT                                ~3      'net'
          4        ADD_ARRAY_ELEMENT                                ~3      'org'
          5        ADD_ARRAY_ELEMENT                                ~3      'us'
          6        ADD_ARRAY_ELEMENT                                ~3      'biz'
          7        ADD_ARRAY_ELEMENT                                ~3      'info'
          8        ASSIGN                                                   !2, ~3
    6     9        INIT_FCALL                                               'uasort'
         10        SEND_REF                                                 !0
         11        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FSubHK%3A6%240'
         12        BIND_LEXICAL                                             ~5, !2
   15    13        SEND_VAL                                                 ~5
         14        DO_ICALL                                                 
   17    15      > RETURN                                                   !0
   18    16*     > RETURN                                                   null

End of function sortbydefault

Function %00%7Bclosure%7D%2Fin%2FSubHK%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/SubHK
function name:  {closure}
number of ops:  26
compiled vars:  !0 = $a, !1 = $b, !2 = $sort, !3 = $tld
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    7     3      > FE_RESET_R                                       $4      !2, ->17
          4    > > FE_FETCH_R                                               $4, !3, ->17
    8     5    >   FETCH_DIM_R                                      ~5      !0, 'tld'
          6        IS_IDENTICAL                                             !3, ~5
          7      > JMPZ                                                     ~6, ->11
    9     8    >   FE_FREE                                                  $4
          9      > RETURN                                                   -1
         10*       JMP                                                      ->16
   10    11    >   FETCH_DIM_R                                      ~7      !1, 'tld'
         12        IS_IDENTICAL                                             !3, ~7
         13      > JMPZ                                                     ~8, ->16
   11    14    >   FE_FREE                                                  $4
         15      > RETURN                                                   1
    7    16    > > JMP                                                      ->4
         17    >   FE_FREE                                                  $4
   14    18        INIT_FCALL                                               'strcmp'
         19        FETCH_DIM_R                                      ~9      !0, 'tld'
         20        SEND_VAL                                                 ~9
         21        FETCH_DIM_R                                      ~10     !1, 'tld'
         22        SEND_VAL                                                 ~10
         23        DO_ICALL                                         $11     
         24      > RETURN                                                   $11
   15    25*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FSubHK%3A6%240

Function %00%7Bclosure%7D%2Fin%2FSubHK%3A23%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SubHK
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $d, !1 = $name, !2 = $tld
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   24     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '.'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        FETCH_LIST_R                                     $4      $3, 0
          6        ASSIGN                                                   !1, $4
          7        FETCH_LIST_R                                     $6      $3, 1
          8        ASSIGN                                                   !2, $6
          9        FREE                                                     $3
   25    10        INIT_ARRAY                                       ~8      !1, 'name'
         11        ADD_ARRAY_ELEMENT                                ~8      !2, 'tld'
         12      > RETURN                                                   ~8
   26    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FSubHK%3A23%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.64 ms | 1407 KiB | 24 Q