3v4l.org

run code in 300+ PHP versions simultaneously
<?php $title = ['gold','blue night','silver morning','about earth','sun vs king','blue night','about earth','gold','about earth']; $value_counts = array_count_values($title); #print_r($value_counts); $expected_result = []; foreach($value_counts as $k=>$v){ if($v<2){ $expected_result[] = $k; }else{ $expected_result[] = $k; for($i=2;$i<=$v;$i++){ $expected_result[] = $k."-".$i; } } } print_r($expected_result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 26
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 26
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 18
Branch analysis from position: 25
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 18
Branch analysis from position: 25
Branch analysis from position: 18
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/Hj1Yg
function name:  (null)
number of ops:  31
compiled vars:  !0 = $title, !1 = $value_counts, !2 = $expected_result, !3 = $v, !4 = $k, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL                                               'array_count_values'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !1, $7
    6     5        ASSIGN                                                   !2, <array>
    7     6      > FE_RESET_R                                       $10     !1, ->26
          7    > > FE_FETCH_R                                       ~11     $10, !3, ->26
          8    >   ASSIGN                                                   !4, ~11
    8     9        IS_SMALLER                                               !3, 2
         10      > JMPZ                                                     ~13, ->14
    9    11    >   ASSIGN_DIM                                               !2
         12        OP_DATA                                                  !4
    8    13      > JMP                                                      ->25
   11    14    >   ASSIGN_DIM                                               !2
         15        OP_DATA                                                  !4
   12    16        ASSIGN                                                   !5, 2
         17      > JMP                                                      ->23
   13    18    >   CONCAT                                           ~18     !4, '-'
         19        CONCAT                                           ~19     ~18, !5
         20        ASSIGN_DIM                                               !2
         21        OP_DATA                                                  ~19
   12    22        PRE_INC                                                  !5
         23    >   IS_SMALLER_OR_EQUAL                                      !5, !3
         24      > JMPNZ                                                    ~21, ->18
    7    25    > > JMP                                                      ->7
         26    >   FE_FREE                                                  $10
   18    27        INIT_FCALL                                               'print_r'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.69 ms | 1439 KiB | 15 Q