3v4l.org

run code in 300+ PHP versions simultaneously
<?php $x = [ 123 => ['name' => 'xxx'], 456 => ['name' => 'yyy'], ]; echo \array_key_exists(123, $x) ? 'yes' : 'no'; echo "\n"; $x = [ ['id' => 123, 'name' => 'xxx'], ['id' => 456, 'name' => 'yyy'], ]; $check = 123; $y = \array_filter($x, function ($value) use ($check) { return $value['id'] === $check; }); echo \count($y) ? 'yes' : 'no'; // if array child id === 123 in any of the children, // then echo yes, // (without using a loop, and by using an array function)
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
Branch analysis from position: 21
filename:       /in/Hah3t
function name:  (null)
number of ops:  24
compiled vars:  !0 = $x, !1 = $check, !2 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ARRAY_KEY_EXISTS                                         123, !0
          2      > JMPZ                                                     ~4, ->5
          3    >   QM_ASSIGN                                        ~5      'yes'
          4      > JMP                                                      ->6
          5    >   QM_ASSIGN                                        ~5      'no'
          6    >   ECHO                                                     ~5
    9     7        ECHO                                                     '%0A'
   11     8        ASSIGN                                                   !0, <array>
   16     9        ASSIGN                                                   !1, 123
   18    10        INIT_FCALL                                               'array_filter'
         11        SEND_VAR                                                 !0
         12        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FHah3t%3A18%240'
         13        BIND_LEXICAL                                             ~8, !1
   20    14        SEND_VAL                                                 ~8
         15        DO_ICALL                                         $9      
   18    16        ASSIGN                                                   !2, $9
   22    17        COUNT                                            ~11     !2
         18      > JMPZ                                                     ~11, ->21
         19    >   QM_ASSIGN                                        ~12     'yes'
         20      > JMP                                                      ->22
         21    >   QM_ASSIGN                                        ~12     'no'
         22    >   ECHO                                                     ~12
   27    23      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FHah3t%3A18%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Hah3t
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $value, !1 = $check
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   19     2        FETCH_DIM_R                                      ~2      !0, 'id'
          3        IS_IDENTICAL                                     ~3      !1, ~2
          4      > RETURN                                                   ~3
   20     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FHah3t%3A18%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.1 ms | 1401 KiB | 15 Q