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($arr, function($item) use($newItem) { $item['idproduct'] != $newItem['idproduct']; }); var_dump($filtered); if($filtered) die('exists'); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Im7EJ
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          
   18     5      > RETURN                                                   1

Function addoroverride:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Im7EJ
function name:  addOrOverride
number of ops:  15
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        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FIm7EJ%3A12%240'
          5        BIND_LEXICAL                                             ~3, !1
   14     6        SEND_VAL                                                 ~3
          7        DO_ICALL                                         $4      
   12     8        ASSIGN                                                   !2, $4
   16     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
   17    12      > JMPZ                                                     !2, ->14
         13    > > EXIT                                                     'exists'
   18    14    > > RETURN                                                   null

End of function addoroverride

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

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.75 ms | 1388 KiB | 17 Q