3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( 0 => array ( 'id' => 1, 'user_id' => 15, 'booked' => '2020-08-01', 'sendin' => '2020-08-03', 'pickup' => '2020-08-08', 'duration' => 5 ), 1 => array ( 'id' => 2, 'user_id' => 15, 'booked' => '2020-08-01', 'sendin' => '2020-08-03', 'pickup' => '2020-08-08', 'duration' => 5 ) ); $user_id = 15; $ids = array_map(function ($a) { return $a['id']; }, array_filter($array, function ($a) use ($user_id) { return $a['user_id'] == $user_id; }) ); print_r($ids); $ids = array_map(function ($k) use ($array) { return $array[$k]['id']; }, array_keys(array_column($array, 'user_id'), $user_id) ); print_r($ids);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XjbvS
function name:  (null)
number of ops:  36
compiled vars:  !0 = $array, !1 = $user_id, !2 = $ids
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   24     1        ASSIGN                                                   !1, 15
   26     2        INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          4        SEND_VAL                                                 ~5
   27     5        INIT_FCALL                                               'array_filter'
          6        SEND_VAR                                                 !0
   28     7        DECLARE_LAMBDA_FUNCTION                          ~6      [1]
          8        BIND_LEXICAL                                             ~6, !1
   30     9        SEND_VAL                                                 ~6
   27    10        DO_ICALL                                         $7      
   30    11        SEND_VAR                                                 $7
   26    12        DO_ICALL                                         $8      
         13        ASSIGN                                                   !2, $8
   32    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                                 
   34    17        INIT_FCALL                                               'array_map'
         18        DECLARE_LAMBDA_FUNCTION                          ~11     [2]
         19        BIND_LEXICAL                                             ~11, !0
         20        SEND_VAL                                                 ~11
   35    21        INIT_FCALL                                               'array_keys'
         22        INIT_FCALL                                               'array_column'
         23        SEND_VAR                                                 !0
         24        SEND_VAL                                                 'user_id'
         25        DO_ICALL                                         $12     
         26        SEND_VAR                                                 $12
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                         $13     
         29        SEND_VAR                                                 $13
   34    30        DO_ICALL                                         $14     
         31        ASSIGN                                                   !2, $14
   37    32        INIT_FCALL                                               'print_r'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                                 
         35      > 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/XjbvS
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        FETCH_DIM_R                                      ~1      !0, 'id'
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XjbvS
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $a, !1 = $user_id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   29     2        FETCH_DIM_R                                      ~2      !0, 'user_id'
          3        IS_EQUAL                                         ~3      !1, ~2
          4      > RETURN                                                   ~3
   30     5*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XjbvS
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $k, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_R                                      ~2      !1, !0
          3        FETCH_DIM_R                                      ~3      ~2, 'id'
          4      > RETURN                                                   ~3
          5*     > RETURN                                                   null

End of Dynamic Function 2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.32 ms | 1446 KiB | 18 Q