3v4l.org

run code in 300+ PHP versions simultaneously
<?php $in = [ '2,24', '2,2,9,12' ]; $out = []; foreach($in as $item) { $norm = explode(',', $item); $ar = array_count_values($norm); $pos = []; $out[] = &$pos; array_walk($ar, function ($val, $key) use(&$pos) { if($val > 1) { $pos[] = $key . '(' . $val . ')'; } else { $pos[] = $key; } }); unset($pos); } foreach($out as $listItem) { echo implode(',', $listItem) , PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 24
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 34
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 34
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 24
filename:       /in/XGXNQ
function name:  (null)
number of ops:  36
compiled vars:  !0 = $in, !1 = $out, !2 = $item, !3 = $norm, !4 = $ar, !5 = $pos, !6 = $listItem
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   10     2      > FE_RESET_R                                       $9      !0, ->24
          3    > > FE_FETCH_R                                               $9, !2, ->24
   11     4    >   INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '%2C'
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $10     
          8        ASSIGN                                                   !3, $10
   12     9        INIT_FCALL                                               'array_count_values'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $12     
         12        ASSIGN                                                   !4, $12
   13    13        ASSIGN                                                   !5, <array>
   14    14        FETCH_DIM_W                                      $15     !1
         15        ASSIGN_REF                                               $15, !5
   15    16        INIT_FCALL                                               'array_walk'
         17        SEND_REF                                                 !4
         18        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FXGXNQ%3A15%240'
         19        BIND_LEXICAL                                             ~17, !5
   21    20        SEND_VAL                                                 ~17
         21        DO_ICALL                                                 
   22    22        UNSET_CV                                                 !5
   10    23      > JMP                                                      ->3
         24    >   FE_FREE                                                  $9
   25    25      > FE_RESET_R                                       $19     !1, ->34
         26    > > FE_FETCH_R                                               $19, !6, ->34
   26    27    >   INIT_FCALL                                               'implode'
         28        SEND_VAL                                                 '%2C'
         29        SEND_VAR                                                 !6
         30        DO_ICALL                                         $20     
         31        ECHO                                                     $20
         32        ECHO                                                     '%0A'
   25    33      > JMP                                                      ->26
         34    >   FE_FREE                                                  $19
   27    35      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FXGXNQ%3A15%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XGXNQ
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $val, !1 = $key, !2 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   16     3        IS_SMALLER                                               1, !0
          4      > JMPZ                                                     ~3, ->11
   17     5    >   CONCAT                                           ~5      !1, '%28'
          6        CONCAT                                           ~6      ~5, !0
          7        CONCAT                                           ~7      ~6, '%29'
          8        ASSIGN_DIM                                               !2
          9        OP_DATA                                                  ~7
         10      > JMP                                                      ->13
   19    11    >   ASSIGN_DIM                                               !2
         12        OP_DATA                                                  !1
   21    13    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FXGXNQ%3A15%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.35 ms | 1400 KiB | 21 Q