3v4l.org

run code in 300+ PHP versions simultaneously
<?php function balancedTagCloud(array $values, array $priorities): array { $low = min($priorities) - 1; $high = max($priorities) - $low; return array_map( fn($v, $p) => sprintf( '<h%1$d>%2$s</h%1$d>', ceil(($p - $low) / $high * 6), $v ), $values, $priorities ); } $artist = ["the roots", "michael jackson", "billy idol", "more", "and more", "and_YET_MORE"]; $counts = [ 'original' => [5, 3, 9, 1, 1, 3], 'no_ones' => [5, 3, 9, 7, 7, 3], 'skewed' => [5, 3, 9, 7, 111, 3], 'all_same' => [5, 5, 5, 5, 5, 5], 'only_two' => [9, 20, 9, 20, 9, 20], ]; foreach ($counts as $count) { echo implode("\n", balancedTagCloud($artist, $count)); echo "\n---\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/1UgZT
function name:  (null)
number of ops:  17
compiled vars:  !0 = $artist, !1 = $counts, !2 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, <array>
   19     1        ASSIGN                                                   !1, <array>
   26     2      > FE_RESET_R                                       $5      !1, ->15
          3    > > FE_FETCH_R                                               $5, !2, ->15
   27     4    >   INIT_FCALL                                               'implode'
          5        SEND_VAL                                                 '%0A'
          6        INIT_FCALL                                               'balancedtagcloud'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !2
          9        DO_FCALL                                      0  $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                         $7      
         12        ECHO                                                     $7
   28    13        ECHO                                                     '%0A---%0A'
   26    14      > JMP                                                      ->3
         15    >   FE_FREE                                                  $5
   29    16      > RETURN                                                   1

Function balancedtagcloud:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1UgZT
function name:  balancedTagCloud
number of ops:  24
compiled vars:  !0 = $values, !1 = $priorities, !2 = $low, !3 = $high
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'min'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $4      
          5        SUB                                              ~5      $4, 1
          6        ASSIGN                                                   !2, ~5
    6     7        INIT_FCALL                                               'max'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $7      
         10        SUB                                              ~8      $7, !2
         11        ASSIGN                                                   !3, ~8
    7    12        INIT_FCALL                                               'array_map'
    8    13        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F1UgZT%3A8%240'
         14        BIND_LEXICAL                                             ~10, !2
         15        BIND_LEXICAL                                             ~10, !3
   12    16        SEND_VAL                                                 ~10
   13    17        SEND_VAR                                                 !0
   14    18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $11     
         20        VERIFY_RETURN_TYPE                                       $11
         21      > RETURN                                                   $11
   16    22*       VERIFY_RETURN_TYPE                                       
         23*     > RETURN                                                   null

End of function balancedtagcloud

Function %00%7Bclosure%7D%2Fin%2F1UgZT%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1UgZT
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $v, !1 = $p, !2 = $low, !3 = $high
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
          4        INIT_FCALL                                               'sprintf'
    9     5        SEND_VAL                                                 '%3Ch%251%24d%3E%252%24s%3C%2Fh%251%24d%3E'
   10     6        INIT_FCALL                                               'ceil'
          7        SUB                                              ~4      !1, !2
          8        DIV                                              ~5      ~4, !3
          9        MUL                                              ~6      ~5, 6
         10        SEND_VAL                                                 ~6
         11        DO_ICALL                                         $7      
         12        SEND_VAR                                                 $7
   11    13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $8      
         15      > RETURN                                                   $8
   12    16*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
133.77 ms | 1407 KiB | 26 Q