3v4l.org

run code in 300+ PHP versions simultaneously
<?php function transformQuestionnaire($arr) { $new_arr = array(); foreach ($arr as $array){ if (!in_array($array[0], array_keys($new_arr))){ //not a double $new_arr[$key] = $array[1]; } else { //Append it to the existing value $new_arr[$key] .= '|' . $array[1]; } } return $new_arr; } $input = array( array("one", "potato"), array("two", "fries"), array("one", "ketchup"), array("two", "steak")); print(var_dump(transformQuestionnaire($input))); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/68bQP
function name:  (null)
number of ops:  9
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   16     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'transformquestionnaire'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                         $3      
          7        ECHO                                                     $3
   18     8      > RETURN                                                   1

Function transformquestionnaire:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/68bQP
function name:  transformQuestionnaire
number of ops:  26
compiled vars:  !0 = $arr, !1 = $new_arr, !2 = $array, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, <array>
    4     2      > FE_RESET_R                                       $5      !0, ->23
          3    > > FE_FETCH_R                                               $5, !2, ->23
    5     4    >   INIT_FCALL                                               'in_array'
          5        FETCH_DIM_R                                      ~6      !2, 0
          6        SEND_VAL                                                 ~6
          7        INIT_FCALL                                               'array_keys'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $7      
         10        SEND_VAR                                                 $7
         11        DO_ICALL                                         $8      
         12        BOOL_NOT                                         ~9      $8
         13      > JMPZ                                                     ~9, ->18
    6    14    >   FETCH_DIM_R                                      ~11     !2, 1
         15        ASSIGN_DIM                                               !1, !3
         16        OP_DATA                                                  ~11
         17      > JMP                                                      ->22
    8    18    >   FETCH_DIM_R                                      ~13     !2, 1
         19        CONCAT                                           ~14     '%7C', ~13
         20        ASSIGN_DIM_OP                .=               8          !1, !3
         21        OP_DATA                                                  ~14
    4    22    > > JMP                                                      ->3
         23    >   FE_FREE                                                  $5
   11    24      > RETURN                                                   !1
   12    25*     > RETURN                                                   null

End of function transformquestionnaire

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.23 ms | 1403 KiB | 20 Q