3v4l.org

run code in 300+ PHP versions simultaneously
<?php $id=5; $allProducts[] = array('itemid'=>$id,'qty' => 1); $allProducts[] = array('itemid'=>6,'qty' => 1); // old version if(array_search($id,array_column($allProducts, 'itemid'))) { echo "an item was found\n"; // will not work } else { echo "NO Item was found, though it should be there\n"; } // corrected version if(array_search($id,array_column($allProducts, 'itemid')) !== false) { echo "an item was found and has the key " .array_search($id,array_column($allProducts, 'itemid')); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 39
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 39
Branch analysis from position: 29
Branch analysis from position: 39
filename:       /in/m62Ya
function name:  (null)
number of ops:  40
compiled vars:  !0 = $id, !1 = $allProducts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 5
    4     1        INIT_ARRAY                                       ~4      !0, 'itemid'
          2        ADD_ARRAY_ELEMENT                                ~4      1, 'qty'
          3        ASSIGN_DIM                                               !1
          4        OP_DATA                                                  ~4
    5     5        ASSIGN_DIM                                               !1
          6        OP_DATA                                                  <array>
    8     7        INIT_FCALL                                               'array_search'
          8        SEND_VAR                                                 !0
          9        INIT_FCALL                                               'array_column'
         10        SEND_VAR                                                 !1
         11        SEND_VAL                                                 'itemid'
         12        DO_ICALL                                         $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                         $7      
         15      > JMPZ                                                     $7, ->18
    9    16    >   ECHO                                                     'an+item+was+found%0A'
         17      > JMP                                                      ->19
   11    18    >   ECHO                                                     'NO+Item+was+found%2C+though+it+should+be+there%0A'
   15    19    >   INIT_FCALL                                               'array_search'
         20        SEND_VAR                                                 !0
         21        INIT_FCALL                                               'array_column'
         22        SEND_VAR                                                 !1
         23        SEND_VAL                                                 'itemid'
         24        DO_ICALL                                         $8      
         25        SEND_VAR                                                 $8
         26        DO_ICALL                                         $9      
         27        TYPE_CHECK                                  1018          $9
         28      > JMPZ                                                     ~10, ->39
   16    29    >   INIT_FCALL                                               'array_search'
         30        SEND_VAR                                                 !0
         31        INIT_FCALL                                               'array_column'
         32        SEND_VAR                                                 !1
         33        SEND_VAL                                                 'itemid'
         34        DO_ICALL                                         $11     
         35        SEND_VAR                                                 $11
         36        DO_ICALL                                         $12     
         37        CONCAT                                           ~13     'an+item+was+found+and+has+the+key+', $12
         38        ECHO                                                     ~13
   17    39    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.41 ms | 1405 KiB | 17 Q