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[$array[0]] = $array[1]; } else { //Append it to the existing value $new_arr[$array[0]] .= '|' . $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/s3nDJ
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 = 25
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 25
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/s3nDJ
function name:  transformQuestionnaire
number of ops:  28
compiled vars:  !0 = $arr, !1 = $new_arr, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, <array>
    4     2      > FE_RESET_R                                       $4      !0, ->25
          3    > > FE_FETCH_R                                               $4, !2, ->25
    5     4    >   INIT_FCALL                                               'in_array'
          5        FETCH_DIM_R                                      ~5      !2, 0
          6        SEND_VAL                                                 ~5
          7        INIT_FCALL                                               'array_keys'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                         $7      
         12        BOOL_NOT                                         ~8      $7
         13      > JMPZ                                                     ~8, ->19
    6    14    >   FETCH_DIM_R                                      ~9      !2, 0
         15        FETCH_DIM_R                                      ~11     !2, 1
         16        ASSIGN_DIM                                               !1, ~9
         17        OP_DATA                                                  ~11
         18      > JMP                                                      ->24
    8    19    >   FETCH_DIM_R                                      ~12     !2, 0
         20        FETCH_DIM_R                                      ~14     !2, 1
         21        CONCAT                                           ~15     '%7C', ~14
         22        ASSIGN_DIM_OP                .=               8          !1, ~12
         23        OP_DATA                                                  ~15
    4    24    > > JMP                                                      ->3
         25    >   FE_FREE                                                  $4
   11    26      > RETURN                                                   !1
   12    27*     > RETURN                                                   null

End of function transformquestionnaire

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.51 ms | 1394 KiB | 20 Q