3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = ["ia", "ai", "go", "og", "og", "cr", "og", "rc"]; $new = array_reduce($arr, function ($acc, $item) { if (!in_array($item, $acc) && !in_array(strrev($item), $acc)) { array_push($acc, $item); } return $acc; }, []); print_r($new); //Array ( [0] => ia [1] => go [2] => cr )
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SYgPk
function name:  (null)
number of ops:  12
compiled vars:  !0 = $arr, !1 = $new
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    5     1        INIT_FCALL                                                   'array_reduce'
          2        SEND_VAR                                                     !0
          3        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
   13     4        SEND_VAL                                                     ~3
          5        SEND_VAL                                                     <array>
    5     6        DO_ICALL                                             $4      
          7        ASSIGN                                                       !1, $4
   15     8        INIT_FCALL                                                   'print_r'
          9        SEND_VAR                                                     !1
         10        DO_ICALL                                                     
   16    11      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 11
filename:       /in/SYgPk
function name:  {closure:/in/SYgPk:5}
number of ops:  18
compiled vars:  !0 = $acc, !1 = $item
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    7     2        FRAMELESS_ICALL_2                in_array            ~2      !1, !0
          3        BOOL_NOT                                             ~3      ~2
          4      > JMPZ_EX                                              ~3      ~3, ->11
          5    >   INIT_FCALL                                                   'strrev'
          6        SEND_VAR                                                     !1
          7        DO_ICALL                                             $4      
          8        FRAMELESS_ICALL_2                in_array            ~5      $4, !0
          9        BOOL_NOT                                             ~6      ~5
         10        BOOL                                                 ~3      ~6
         11    > > JMPZ                                                         ~3, ->16
    8    12    >   INIT_FCALL                                                   'array_push'
         13        SEND_REF                                                     !0
         14        SEND_VAR                                                     !1
         15        DO_ICALL                                                     
   11    16    > > RETURN                                                       !0
   13    17*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
249.56 ms | 2072 KiB | 17 Q