3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = array(); for ($i = 0; $i < 200000; $i++) { $a[] = array( 'name' => 'John', 'city' => 'New York', 'age' => $i % 200 == 0 ? 21 : 28 ); } $time = microtime(true); $filtered = array(); foreach ($a as $item) { if ($item['age'] == 21) $filtered[] = $item; } $time = microtime(true) - $time; echo 'explicit foreach ' . number_format($time, 3) . ' seconds and returned ' . count($filtered) . " entries\n";
based on sX8ZF
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 16
Branch analysis from position: 16
Jump found. Position 1 = 18, Position 2 = 3
Branch analysis from position: 18
Jump found. Position 1 = 24, Position 2 = 31
Branch analysis from position: 24
Jump found. Position 1 = 25, Position 2 = 31
Branch analysis from position: 25
Jump found. Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
Jump found. Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 30
Branch analysis from position: 31
Jump found. Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 3
Jump found. Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
Jump found. Position 1 = 11
Branch analysis from position: 11
Jump found. Position 1 = 18, Position 2 = 3
Branch analysis from position: 18
Branch analysis from position: 3
Branch analysis from position: 10
Jump found. Position 1 = 18, Position 2 = 3
Branch analysis from position: 18
Branch analysis from position: 3
filename:       /in/CjIMW
function name:  (null)
number of ops:  50
compiled vars:  !0 = $a, !1 = $i, !2 = $time, !3 = $filtered, !4 = $item
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   ASSIGN                                                   !0, <array>
   5     1        ASSIGN                                                   !1, 0
         2      > JMP                                                      ->16
   8     3    >   INIT_ARRAY                                       ~8      'John', 'name'
   9     4        ADD_ARRAY_ELEMENT                                ~8      'New+York', 'city'
  10     5        MOD                                              ~9      !1, 200
         6        IS_EQUAL                                         ~10     ~9, 0
         7      > JMPZ                                                     ~10, ->10
         8    >   QM_ASSIGN                                        ~11     21
         9      > JMP                                                      ->11
        10    >   QM_ASSIGN                                        ~11     28
        11    >   ADD_ARRAY_ELEMENT                                ~8      ~11, 'age'
   7    12        ASSIGN_DIM                                               !0
  10    13        OP_DATA                                                  ~8
   5    14        POST_INC                                         ~12     !1
        15        FREE                                                     ~12
        16    >   IS_SMALLER                                       ~13     !1, 200000
        17      > JMPNZ                                                    ~13, ->3
  14    18    >   INIT_FCALL                                               'microtime'
        19        SEND_VAL                                                 <true>
        20        DO_ICALL                                         $14     
        21        ASSIGN                                                   !2, $14
  16    22        ASSIGN                                                   !3, <array>
  18    23      > FE_RESET_R                                       $17     !0, ->31
        24    > > FE_FETCH_R                                               $17, !4, ->31
  20    25    >   FETCH_DIM_R                                      $18     !4, 'age'
        26        IS_EQUAL                                         ~19     $18, 21
        27      > JMPZ                                                     ~19, ->30
        28    >   ASSIGN_DIM                                               !3
        29        OP_DATA                                                  !4
        30    > > JMP                                                      ->24
        31    >   FE_FREE                                                  $17
  23    32        INIT_FCALL                                               'microtime'
        33        SEND_VAL                                                 <true>
        34        DO_ICALL                                         $21     
        35        SUB                                              ~22     $21, !2
        36        ASSIGN                                                   !2, ~22
  25    37        INIT_FCALL                                               'number_format'
        38        SEND_VAR                                                 !2
        39        SEND_VAL                                                 3
        40        DO_ICALL                                         $24     
        41        CONCAT                                           ~25     'explicit+foreach+', $24
        42        CONCAT                                           ~26     ~25, '+seconds+and+returned+'
        43        INIT_FCALL                                               'count'
        44        SEND_VAR                                                 !3
        45        DO_ICALL                                         $27     
        46        CONCAT                                           ~28     ~26, $27
        47        CONCAT                                           ~29     ~28, '+entries%0A'
        48        ECHO                                                     ~29
        49      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 7.2.0