3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( array('name' => 'User 1', 'email' => 'user.1@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 2', 'email' => 'user.2@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 3', 'email' => 'user.3@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 4', 'email' => 'user.4@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 5', 'email' => 'user.5@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 6', 'email' => 'user.6@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 7', 'email' => 'user.7@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 8', 'email' => 'user.8@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 9', 'email' => 'user.9@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 10', 'email' => 'user.10@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), array('name' => 'User 11', 'email' => 'user.11@example.com', 'sex' => 1, 'active' => 1, 'banned' => 0, ), ); $start_time1 = microtime(TRUE); $outputData = array(); foreach($data as $id => $user){ $outputData[] = array( 'name' => $user['name'], 'email' => $user['email'], 'banned' => $user['banned'], ); } //var_dump($outputData); $end_time1 = microtime(TRUE); echo 'Foreach: '.number_format($end_time1 - $start_time1, 5) ."\n\n"; $start_time2 = microtime(TRUE); $outputData = array_map(function($user){ return array( 'name' => $user['name'], 'email' => $user['email'], 'banned' => $user['banned'], ); }, $data); //var_dump($outputData); $end_time2 = microtime(TRUE); echo 'Array_map: '.number_format($end_time2 - $start_time2, 5) ."\n\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/7tOWo
function name:  (null)
number of ops:  54
compiled vars:  !0 = $data, !1 = $start_time1, !2 = $outputData, !3 = $user, !4 = $id, !5 = $end_time1, !6 = $start_time2, !7 = $end_time2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $9      
          4        ASSIGN                                                   !1, $9
   20     5        ASSIGN                                                   !2, <array>
   21     6      > FE_RESET_R                                       $12     !0, ->18
          7    > > FE_FETCH_R                                       ~13     $12, !3, ->18
          8    >   ASSIGN                                                   !4, ~13
   24     9        FETCH_DIM_R                                      ~16     !3, 'name'
         10        INIT_ARRAY                                       ~17     ~16, 'name'
   25    11        FETCH_DIM_R                                      ~18     !3, 'email'
         12        ADD_ARRAY_ELEMENT                                ~17     ~18, 'email'
   26    13        FETCH_DIM_R                                      ~19     !3, 'banned'
         14        ADD_ARRAY_ELEMENT                                ~17     ~19, 'banned'
   23    15        ASSIGN_DIM                                               !2
   26    16        OP_DATA                                                  ~17
   21    17      > JMP                                                      ->7
         18    >   FE_FREE                                                  $12
   30    19        INIT_FCALL                                               'microtime'
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $20     
         22        ASSIGN                                                   !5, $20
   32    23        INIT_FCALL                                               'number_format'
         24        SUB                                              ~22     !5, !1
         25        SEND_VAL                                                 ~22
         26        SEND_VAL                                                 5
         27        DO_ICALL                                         $23     
         28        CONCAT                                           ~24     'Foreach%3A+', $23
         29        CONCAT                                           ~25     ~24, '%0A%0A'
         30        ECHO                                                     ~25
   35    31        INIT_FCALL                                               'microtime'
         32        SEND_VAL                                                 <true>
         33        DO_ICALL                                         $26     
         34        ASSIGN                                                   !6, $26
   37    35        INIT_FCALL                                               'array_map'
         36        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7tOWo%3A37%240'
   43    37        SEND_VAL                                                 ~28
         38        SEND_VAR                                                 !0
         39        DO_ICALL                                         $29     
   37    40        ASSIGN                                                   !2, $29
   45    41        INIT_FCALL                                               'microtime'
         42        SEND_VAL                                                 <true>
         43        DO_ICALL                                         $31     
         44        ASSIGN                                                   !7, $31
   47    45        INIT_FCALL                                               'number_format'
         46        SUB                                              ~33     !7, !6
         47        SEND_VAL                                                 ~33
         48        SEND_VAL                                                 5
         49        DO_ICALL                                         $34     
         50        CONCAT                                           ~35     'Array_map%3A+', $34
         51        CONCAT                                           ~36     ~35, '%0A%0A'
         52        ECHO                                                     ~36
         53      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F7tOWo%3A37%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7tOWo
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $user
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   39     1        FETCH_DIM_R                                      ~1      !0, 'name'
          2        INIT_ARRAY                                       ~2      ~1, 'name'
   40     3        FETCH_DIM_R                                      ~3      !0, 'email'
          4        ADD_ARRAY_ELEMENT                                ~2      ~3, 'email'
   41     5        FETCH_DIM_R                                      ~4      !0, 'banned'
          6        ADD_ARRAY_ELEMENT                                ~2      ~4, 'banned'
          7      > RETURN                                                   ~2
   43     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7tOWo%3A37%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.02 ms | 1400 KiB | 19 Q