3v4l.org

run code in 300+ 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 = 66
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 66
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 65
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 38
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 38
2 jumps found. (Code = 77) Position 1 = 48, Position 2 = 61
Branch analysis from position: 48
2 jumps found. (Code = 78) Position 1 = 49, Position 2 = 61
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 61
Branch analysis from position: 65
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 66
filename:       /in/sk44Q
function name:  (null)
number of ops:  71
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, ->66
         11    > > FE_FETCH_R                                       ~14     $13, !4, ->66
         12    >   ASSIGN                                                   !5, ~14
   11    13        INIT_FCALL                                               'in_array'
         14        SEND_VAR                                                 !5
         15        INIT_FCALL                                               'array_keys'
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                         $16     
         18        SEND_VAR                                                 $16
         19        DO_ICALL                                         $17     
         20        BOOL_NOT                                         ~18     $17
         21      > JMPZ                                                     ~18, ->65
   12    22    >   INIT_FCALL                                               'next'
         23        SEND_REF                                                 !1
         24        DO_ICALL                                         $19     
         25        IS_NOT_EQUAL                                             !4, $19
         26      > JMPZ                                                     ~20, ->38
   13    27    >   INIT_FCALL                                               'array_merge'
         28        SEND_VAR                                                 !2
         29        INIT_FCALL                                               'array_fill'
         30        SEND_VAL                                                 0
         31        SEND_VAR                                                 !4
         32        SEND_VAR                                                 !5
         33        DO_ICALL                                         $21     
         34        SEND_VAR                                                 $21
         35        DO_ICALL                                         $22     
         36        ASSIGN                                                   !2, $22
   12    37      > JMP                                                      ->65
   15    38    >   INIT_FCALL                                               'array_intersect'
         39        SEND_VAR                                                 !1
         40        INIT_ARRAY                                       ~24     !4
         41        SEND_VAL                                                 ~24
         42        DO_ICALL                                         $25     
         43        ASSIGN                                                   !3, $25
   16    44        INIT_FCALL                                               'ksort'
         45        SEND_REF                                                 !3
         46        DO_ICALL                                                 
   17    47      > FE_RESET_R                                       $28     !3, ->61
         48    > > FE_FETCH_R                                       ~29     $28, !4, ->61
         49    >   ASSIGN                                                   !6, ~29
   18    50        INIT_FCALL                                               'array_merge'
         51        SEND_VAR                                                 !2
         52        INIT_FCALL                                               'array_fill'
         53        SEND_VAL                                                 0
         54        SEND_VAR                                                 !4
         55        SEND_VAR                                                 !6
         56        DO_ICALL                                         $31     
         57        SEND_VAR                                                 $31
         58        DO_ICALL                                         $32     
         59        ASSIGN                                                   !2, $32
   17    60      > JMP                                                      ->48
         61    >   FE_FREE                                                  $28
   20    62        INIT_FCALL                                               'var_dump'
         63        SEND_VAR                                                 !3
         64        DO_ICALL                                                 
   10    65    > > JMP                                                      ->11
         66    >   FE_FREE                                                  $13
   25    67        INIT_FCALL                                               'var_dump'
         68        SEND_VAR                                                 !2
         69        DO_ICALL                                                 
         70      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.43 ms | 1017 KiB | 23 Q