3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array ( 0 => (object) array ( 'id' => 8, 'book_category' => 'C Program', 'book_id' => 2, 'book_name' => 'C Language', 'book_category_id' => 8, 'book_in_stock' => 5, ), 1 => (object) array ( 'id' => 8, 'book_category' => 'C Program', 'book_id' => 1, 'book_name' => 'C++', 'book_category_id' => 8, 'book_in_stock' => 10, ), '2' => (object) array ( 'id' => 9, 'book_category' => 'English', 'book_id' => 3, 'book_name' => 'Comp Eng', 'book_category_id' => 9, 'book_in_stock' => 5, ), 3 => (object) array ( 'id' => 9, 'book_category' => 'English', 'book_id' => 4, 'book_name' => 'Eng English', 'book_category_id' => 9, 'book_in_stock' => 5, ), ); if( '7.0.0' <= phpversion() ) { echo "with array column:\n"; $key = array_search( 9, array_column( $array, 'id' ) ); } else { function array_column2( $array, $column ) { return array_map ( function( $row ) use( $column ) { return is_object( $row ) ? $row->$column : $row[$column]; } , $array ); } echo "with array column emulation:\n"; $key = array_search( 9, array_column2( $array, 'id' ) ); } echo $key;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 24
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ss0JA
function name:  (null)
number of ops:  37
compiled vars:  !0 = $array, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   CAST                                          8  ~2      <array>
          1        INIT_ARRAY                                       ~3      ~2, 0
   16     2        CAST                                          8  ~4      <array>
          3        ADD_ARRAY_ELEMENT                                ~3      ~4, 1
   25     4        CAST                                          8  ~5      <array>
          5        ADD_ARRAY_ELEMENT                                ~3      ~5, 2
   34     6        CAST                                          8  ~6      <array>
          7        ADD_ARRAY_ELEMENT                                ~3      ~6, 3
    3     8        ASSIGN                                                   !0, ~3
   44     9        INIT_FCALL                                               'phpversion'
         10        DO_ICALL                                         $8      
         11        IS_SMALLER_OR_EQUAL                                      '7.0.0', $8
         12      > JMPZ                                                     ~9, ->24
   46    13    >   ECHO                                                     'with+array+column%3A%0A'
   47    14        INIT_FCALL                                               'array_search'
         15        SEND_VAL                                                 9
         16        INIT_FCALL                                               'array_column'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 'id'
         19        DO_ICALL                                         $10     
         20        SEND_VAR                                                 $10
         21        DO_ICALL                                         $11     
         22        ASSIGN                                                   !1, $11
   44    23      > JMP                                                      ->35
   51    24    >   DECLARE_FUNCTION                                         'array_column2'
   63    25        ECHO                                                     'with+array+column+emulation%3A%0A'
   64    26        INIT_FCALL                                               'array_search'
         27        SEND_VAL                                                 9
         28        INIT_FCALL_BY_NAME                                       'array_column2'
         29        SEND_VAR_EX                                              !0
         30        SEND_VAL_EX                                              'id'
         31        DO_FCALL                                      0  $13     
         32        SEND_VAR                                                 $13
         33        DO_ICALL                                         $14     
         34        ASSIGN                                                   !1, $14
   67    35    >   ECHO                                                     !1
         36      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ss0JA
function name:  array_column2
number of ops:  10
compiled vars:  !0 = $array, !1 = $column
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   53     2        INIT_FCALL                                               'array_map'
   55     3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          4        BIND_LEXICAL                                             ~2, !1
   58     5        SEND_VAL                                                 ~2
   59     6        SEND_VAR                                                 !0
   53     7        DO_ICALL                                         $3      
   59     8      > RETURN                                                   $3
   61     9*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ss0JA
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $row, !1 = $column
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   57     2        TYPE_CHECK                                  256          !0
          3      > JMPZ                                                     ~2, ->7
          4    >   FETCH_OBJ_R                                      ~3      !0, !1
          5        QM_ASSIGN                                        ~4      ~3
          6      > JMP                                                      ->9
          7    >   FETCH_DIM_R                                      ~5      !0, !1
          8        QM_ASSIGN                                        ~4      ~5
          9    > > RETURN                                                   ~4
   58    10*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.14 ms | 1008 KiB | 17 Q