3v4l.org

run code in 300+ PHP versions simultaneously
<?php function transformQuestionnaire($arr) { $new_arr = array(); foreach ($arr as $array){ $key = reset($array); $val = end($array); if (!in_array($key, array_keys($new_arr))){ //not a double $new_arr[$key] = $val; } else { //Append it to the existing value $new_arr[$key] .= '|' . $val; } } 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/Q5F5c
function name:  (null)
number of ops:  9
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, <array>
   18     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
   20     8      > RETURN                                                   1

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

End of function transformquestionnaire

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.73 ms | 1407 KiB | 24 Q