3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Задача 18: Дадени са два едномерни масива с естествени числа. Да се състави програма, която сравнява всички числа с еднакви индекси от двата масива и записва в трети масив, по-голямото от двете числа. Да се изведе съдържанието и на трите масива Пример: 18,19,32,1,3, 4, 5, 6, 7, 8 1, 2, 3,4,5,16,17,18,27,11 Изход: 18,19,32 ,4,5,16,17,18,27,11 */ $arr1 = [18,19,32,1,3, 4, 5, 6, 7, 8]; $arr2 = [18,19,32,4,5,16,17,18,27,11]; $result = []; foreach ($arr1 as $key => $value) { $result[$key] = (isset($arr2[$key]) && $arr1[$key] > $arr2[$key]) ? $arr1[$key] : $arr2[$key]; } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 21
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/4sail
function name:  (null)
number of ops:  26
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $result, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, <array>
   19     1        ASSIGN                                                   !1, <array>
   21     2        ASSIGN                                                   !2, <array>
   23     3      > FE_RESET_R                                       $8      !0, ->21
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->21
          5    >   ASSIGN                                                   !4, ~9
   24     6        ISSET_ISEMPTY_DIM_OBJ                         0  ~12     !1, !4
          7      > JMPZ_EX                                          ~12     ~12, ->12
          8    >   FETCH_DIM_R                                      ~13     !0, !4
          9        FETCH_DIM_R                                      ~14     !1, !4
         10        IS_SMALLER                                       ~15     ~14, ~13
         11        BOOL                                             ~12     ~15
         12    > > JMPZ                                                     ~12, ->16
         13    >   FETCH_DIM_R                                      ~16     !0, !4
         14        QM_ASSIGN                                        ~17     ~16
         15      > JMP                                                      ->18
         16    >   FETCH_DIM_R                                      ~18     !1, !4
         17        QM_ASSIGN                                        ~17     ~18
         18    >   ASSIGN_DIM                                               !2, !4
         19        OP_DATA                                                  ~17
   23    20      > JMP                                                      ->4
         21    >   FE_FREE                                                  $8
   27    22        INIT_FCALL                                               'print_r'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.86 ms | 1396 KiB | 15 Q