3v4l.org

run code in 300+ PHP versions simultaneously
<?php // result from db $recordset1 = [ [ 'id' => 1337, 'name' => 'Foo', 'age' => '40', 'sex' => 'yes please', ], [ 'id' => 1347, 'name' => 'Foo', 'age' => '40', 'sex' => 'yes please', ], ]; // this I want $recordset = [ 1337 => [ 'name' => 'Foo', 'age' => '40', 'sex' => 'yes please', ], 1347 => [ 'name' => 'Foo', 'age' => '40', 'sex' => 'yes please', ], ]; $result = array_map(function($record){ return array_diff_key($record, ['id'=>1]); }, array_column($recordset, null, 'id')); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MCrX3
function name:  (null)
number of ops:  17
compiled vars:  !0 = $recordset1, !1 = $recordset, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   20     1        ASSIGN                                                   !1, <array>
   33     2        INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMCrX3%3A33%240'
          4        SEND_VAL                                                 ~5
          5        INIT_FCALL                                               'array_column'
          6        SEND_VAR                                                 !1
          7        SEND_VAL                                                 null
          8        SEND_VAL                                                 'id'
          9        DO_ICALL                                         $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                         $7      
         12        ASSIGN                                                   !2, $7
   34    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FMCrX3%3A33%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MCrX3
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $record
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'array_diff_key'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <array>
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMCrX3%3A33%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151 ms | 1395 KiB | 21 Q