3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [9,1,9,1,3,9,1,2,9]; $values = array_count_values($array); arsort($values); //var_dump($values); $result =[]; $same = []; foreach($values as $key => $val){ if(!in_array($key, array_keys($same))){ if(next($values) != $val){ $result = array_merge($result, array_fill(0, $val, $key)); }else{ $same = array_intersect($values, [$val]); Ksort($same); foreach($same as $skey => $val){ $result = array_merge($result, array_fill(0, $val, $skey)); } var_dump($same); } } } var_dump($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 63
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 63
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 62
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 35
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 35
2 jumps found. (Code = 77) Position 1 = 45, Position 2 = 58
Branch analysis from position: 45
2 jumps found. (Code = 78) Position 1 = 46, Position 2 = 58
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 58
Branch analysis from position: 62
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
filename:       /in/sk44Q
function name:  (null)
number of ops:  68
compiled vars:  !0 = $array, !1 = $values, !2 = $result, !3 = $same, !4 = $val, !5 = $key, !6 = $skey
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        INIT_FCALL                                                   'array_count_values'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $8      
          4        ASSIGN                                                       !1, $8
    5     5        INIT_FCALL                                                   'arsort'
          6        SEND_REF                                                     !1
          7        DO_ICALL                                                     
    8     8        ASSIGN                                                       !2, <array>
    9     9        ASSIGN                                                       !3, <array>
   10    10      > FE_RESET_R                                           $13     !1, ->63
         11    > > FE_FETCH_R                                           ~14     $13, !4, ->63
         12    >   ASSIGN                                                       !5, ~14
   11    13        INIT_FCALL                                                   'array_keys'
         14        SEND_VAR                                                     !3
         15        DO_ICALL                                             $16     
         16        FRAMELESS_ICALL_2                in_array            ~17     !5, $16
         17        BOOL_NOT                                             ~18     ~17
         18      > JMPZ                                                         ~18, ->62
   12    19    >   INIT_FCALL                                                   'next'
         20        SEND_REF                                                     !1
         21        DO_ICALL                                             $19     
         22        IS_NOT_EQUAL                                                 !4, $19
         23      > JMPZ                                                         ~20, ->35
   13    24    >   INIT_FCALL                                                   'array_merge'
         25        SEND_VAR                                                     !2
         26        INIT_FCALL                                                   'array_fill'
         27        SEND_VAL                                                     0
         28        SEND_VAR                                                     !4
         29        SEND_VAR                                                     !5
         30        DO_ICALL                                             $21     
         31        SEND_VAR                                                     $21
         32        DO_ICALL                                             $22     
         33        ASSIGN                                                       !2, $22
   12    34      > JMP                                                          ->62
   15    35    >   INIT_FCALL                                                   'array_intersect'
         36        SEND_VAR                                                     !1
         37        INIT_ARRAY                                           ~24     !4
         38        SEND_VAL                                                     ~24
         39        DO_ICALL                                             $25     
         40        ASSIGN                                                       !3, $25
   16    41        INIT_FCALL                                                   'ksort'
         42        SEND_REF                                                     !3
         43        DO_ICALL                                                     
   17    44      > FE_RESET_R                                           $28     !3, ->58
         45    > > FE_FETCH_R                                           ~29     $28, !4, ->58
         46    >   ASSIGN                                                       !6, ~29
   18    47        INIT_FCALL                                                   'array_merge'
         48        SEND_VAR                                                     !2
         49        INIT_FCALL                                                   'array_fill'
         50        SEND_VAL                                                     0
         51        SEND_VAR                                                     !4
         52        SEND_VAR                                                     !6
         53        DO_ICALL                                             $31     
         54        SEND_VAR                                                     $31
         55        DO_ICALL                                             $32     
         56        ASSIGN                                                       !2, $32
   17    57      > JMP                                                          ->45
         58    >   FE_FREE                                                      $28
   20    59        INIT_FCALL                                                   'var_dump'
         60        SEND_VAR                                                     !3
         61        DO_ICALL                                                     
   10    62    > > JMP                                                          ->11
         63    >   FE_FREE                                                      $13
   25    64        INIT_FCALL                                                   'var_dump'
         65        SEND_VAR                                                     !2
         66        DO_ICALL                                                     
         67      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
234.58 ms | 3365 KiB | 22 Q