3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array('idproduct' => 1, 'amount' => 5), array('idproduct' => 2, 'amount' => 10), array('idproduct' => 3, 'amount' => 11), array('idproduct' => 4, 'amount' => 5) ); addOrOverride($arr, array('idproduct' => 4, 'amount' => 5)); function addOrOverride($arr, $newItem) { $filtered = array_filter(function($item) { $item['idproduct'] != $newItem['idproduct']; }, $arr); if($filtered) die('exists'); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ti8cd
function name:  (null)
number of ops:  6
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1        INIT_FCALL_BY_NAME                                       'addOrOverride'
          2        SEND_VAR_EX                                              !0
          3        SEND_VAL_EX                                              <array>
          4        DO_FCALL                                      0          
   17     5      > RETURN                                                   1

Function addoroverride:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ti8cd
function name:  addOrOverride
number of ops:  11
compiled vars:  !0 = $arr, !1 = $newItem, !2 = $filtered
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        INIT_FCALL                                               'array_filter'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fti8cd%3A12%240'
   14     4        SEND_VAL                                                 ~3
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
   12     7        ASSIGN                                                   !2, $4
   16     8      > JMPZ                                                     !2, ->10
          9    > > EXIT                                                     'exists'
   17    10    > > RETURN                                                   null

End of function addoroverride

Function %00%7Bclosure%7D%2Fin%2Fti8cd%3A12%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ti8cd
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $item, !1 = $newItem
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        FETCH_DIM_R                                      ~2      !0, 'idproduct'
          2        FETCH_DIM_R                                      ~3      !1, 'idproduct'
          3        IS_NOT_EQUAL                                     ~4      ~2, ~3
          4        FREE                                                     ~4
   14     5      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fti8cd%3A12%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.07 ms | 1396 KiB | 15 Q