3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Examples 1 & 2 from http://nl3.php.net/array_column $records = array( 4 => array( 'id' => 2135, 'first_name' => 'John', 'last_name' => 'Doe', ), 8 => array( 'id' => 3245, 'first_name' => 'Sally', 'last_name' => 'Smith', ), 2 => array( 'id' => 5342, 'first_name' => 'Jane', 'last_name' => 'Jones', ), '00013411' => array( 'id' => 5623, 'first_name' => 'Peter', 'last_name' => 'Doe', ) ); // Example 1: original indexes are lost =( print_r(array_column($records, 'first_name')); // Example 2: new indexes are 'id' column print_r(array_column($records, 'last_name', 'id')); // Example 3: full objects by 'last_name' print_r(array_column($records, null, 'last_name')); // Example 4: objects instead of arrays? $objects = array_map(function($arr) { return (object)$arr; }, $records); print_r($objects); print_r(array_column($records, 'last_name', 'id'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0fqe7
function name:  (null)
number of ops:  42
compiled vars:  !0 = $records, !1 = $objects
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, <array>
   29     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'first_name'
          5        DO_ICALL                                         $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                                 
   32     8        INIT_FCALL                                               'print_r'
          9        INIT_FCALL                                               'array_column'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 'last_name'
         12        SEND_VAL                                                 'id'
         13        DO_ICALL                                         $5      
         14        SEND_VAR                                                 $5
         15        DO_ICALL                                                 
   35    16        INIT_FCALL                                               'print_r'
         17        INIT_FCALL                                               'array_column'
         18        SEND_VAR                                                 !0
         19        SEND_VAL                                                 null
         20        SEND_VAL                                                 'last_name'
         21        DO_ICALL                                         $7      
         22        SEND_VAR                                                 $7
         23        DO_ICALL                                                 
   38    24        INIT_FCALL                                               'array_map'
         25        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F0fqe7%3A38%240'
         26        SEND_VAL                                                 ~9
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $10     
         29        ASSIGN                                                   !1, $10
   39    30        INIT_FCALL                                               'print_r'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                                 
   40    33        INIT_FCALL                                               'print_r'
         34        INIT_FCALL                                               'array_column'
         35        SEND_VAR                                                 !0
         36        SEND_VAL                                                 'last_name'
         37        SEND_VAL                                                 'id'
         38        DO_ICALL                                         $13     
         39        SEND_VAR                                                 $13
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F0fqe7%3A38%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0fqe7
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        CAST                                          8  ~1      !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F0fqe7%3A38%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.47 ms | 1400 KiB | 19 Q