3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = ["name1","name2","name3","name4"]; $array2 = ["name2","name1","name3","name4"]; $arr = ["-1" => "down", "0" => "same", "1" => "up"]; $result = []; foreach(array_unique($array1) as $k => $v){ $result[$v] = $arr[array_search($v, $array2) <=> $k]; } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/5fpN8
function name:  (null)
number of ops:  24
compiled vars:  !0 = $array1, !1 = $array2, !2 = $arr, !3 = $result, !4 = $v, !5 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    6     3        ASSIGN                                                   !3, <array>
    8     4        INIT_FCALL                                               'array_unique'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $10     
          7      > FE_RESET_R                                       $11     $10, ->19
          8    > > FE_FETCH_R                                       ~12     $11, !4, ->19
          9    >   ASSIGN                                                   !5, ~12
    9    10        INIT_FCALL                                               'array_search'
         11        SEND_VAR                                                 !4
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $15     
         14        SPACESHIP                                        ~16     $15, !5
         15        FETCH_DIM_R                                      ~17     !2, ~16
         16        ASSIGN_DIM                                               !3, !4
         17        OP_DATA                                                  ~17
    8    18      > JMP                                                      ->8
         19    >   FE_FREE                                                  $11
   12    20        INIT_FCALL                                               'print_r'
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.57 ms | 1395 KiB | 19 Q