3v4l.org

run code in 300+ PHP versions simultaneously
<?php $answers = [ [ 'questionid' => '28f68dc4-acc6-4ab7-956d-ca41abf3a4c2', 'answer' => 'Antwoord 89', 'extra' => '', ], [ 'questionid' => '28f-28f68dc4-acc6-4ab7-956d-ca41abf3a4c20', 'answer' => 'Antwoord 20', 'extra' => 'Extra informatie 20', ], [ 'questionid' => 'd8f-28f68dc4-acc6-4ab7-956d-ca41abf3a4c20', 'answer' => 'Antwoord 3', 'extra' => '', ], ]; $questions = [ [ 'questionId' => '28f-28f68dc4-acc6-4ab7-956d-ca41abf3a4c20', 'question' => '1. Question 1', 'type' => 'typequestion/question-text-input', ], ]; $indexedQuestions = []; foreach ($questions as $question) { $id = $question['questionId']; $indexedQuestions[$id] = $question; } $combined = []; foreach ($answers as $answer) { $id = $answer['questionid']; if (isset($indexedQuestions[$id])) { $combined[] = $answer + $indexedQuestions[$id]; } else { $combined[] = $answer; } } print_r($combined);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 26
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 26
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 10
filename:       /in/OahN4
function name:  (null)
number of ops:  31
compiled vars:  !0 = $answers, !1 = $questions, !2 = $indexedQuestions, !3 = $question, !4 = $id, !5 = $combined, !6 = $answer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   21     1        ASSIGN                                                   !1, <array>
   29     2        ASSIGN                                                   !2, <array>
   30     3      > FE_RESET_R                                       $10     !1, ->10
          4    > > FE_FETCH_R                                               $10, !3, ->10
   31     5    >   FETCH_DIM_R                                      ~11     !3, 'questionId'
          6        ASSIGN                                                   !4, ~11
   32     7        ASSIGN_DIM                                               !2, !4
          8        OP_DATA                                                  !3
   30     9      > JMP                                                      ->4
         10    >   FE_FREE                                                  $10
   35    11        ASSIGN                                                   !5, <array>
   36    12      > FE_RESET_R                                       $15     !0, ->26
         13    > > FE_FETCH_R                                               $15, !6, ->26
   37    14    >   FETCH_DIM_R                                      ~16     !6, 'questionid'
         15        ASSIGN                                                   !4, ~16
   38    16        ISSET_ISEMPTY_DIM_OBJ                         0          !2, !4
         17      > JMPZ                                                     ~18, ->23
   39    18    >   FETCH_DIM_R                                      ~20     !2, !4
         19        ADD                                              ~21     !6, ~20
         20        ASSIGN_DIM                                               !5
         21        OP_DATA                                                  ~21
   38    22      > JMP                                                      ->25
   41    23    >   ASSIGN_DIM                                               !5
         24        OP_DATA                                                  !6
   36    25    > > JMP                                                      ->13
         26    >   FE_FREE                                                  $15
   45    27        INIT_FCALL                                               'print_r'
         28        SEND_VAR                                                 !5
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.78 ms | 1001 KiB | 14 Q