3v4l.org

run code in 300+ PHP versions simultaneously
#!/usr/bin/env php <?php function generate_result_array($where) { return array_fill(0, count($where), 0); } function generator($where) { for (;;) { yield rand(0, count($where) - 1); if (42 === rand(0, 100000)) { break; } } }; function main() { $where = [ 'Péché mignon', 'McDo', 'Flunch', 'Cora', 'Pizza', 'Kebab', 'Frites&Co' ]; $results = generate_result_array($where); srand(time()); foreach (generator($where) as $result) { $results[$result]++; } echo $where[array_search(max($results), $results)], "\n"; } main();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2jIWn
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'main'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   1

Function generate_result_array:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2jIWn
function name:  generate_result_array
number of ops:  9
compiled vars:  !0 = $where
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'array_fill'
          2        SEND_VAL                                                 0
          3        COUNT                                            ~1      !0
          4        SEND_VAL                                                 ~1
          5        SEND_VAL                                                 0
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    6     8*     > RETURN                                                   null

End of function generate_result_array

Function generator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 3
Branch analysis from position: 18
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 17
filename:       /in/2jIWn
function name:  generator
number of ops:  19
compiled vars:  !0 = $where
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        GENERATOR_CREATE                                         
    9     2      > JMP                                                      ->17
   10     3    >   INIT_FCALL                                               'rand'
          4        SEND_VAL                                                 0
          5        COUNT                                            ~1      !0
          6        SUB                                              ~2      ~1, 1
          7        SEND_VAL                                                 ~2
          8        DO_ICALL                                         $3      
          9        YIELD                                                    $3
   12    10        INIT_FCALL                                               'rand'
         11        SEND_VAL                                                 0
         12        SEND_VAL                                                 100000
         13        DO_ICALL                                         $5      
         14        IS_IDENTICAL                                             $5, 42
         15      > JMPZ                                                     ~6, ->17
   13    16    > > JMP                                                      ->18
         17    > > JMPNZ                                                    <true>, ->3
   16    18    > > GENERATOR_RETURN                                         

End of function generator

Function main:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/2jIWn
function name:  main
number of ops:  30
compiled vars:  !0 = $where, !1 = $results, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'generate_result_array'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
   22     5        INIT_FCALL                                               'srand'
          6        INIT_FCALL                                               'time'
          7        DO_ICALL                                         $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                                 
   24    10        INIT_FCALL                                               'generator'
         11        SEND_VAR                                                 !0
         12        DO_FCALL                                      0  $8      
         13      > FE_RESET_R                                       $9      $8, ->18
         14    > > FE_FETCH_R                                               $9, !2, ->18
   25    15    >   FETCH_DIM_RW                                     $10     !1, !2
         16        PRE_INC                                                  $10
   24    17      > JMP                                                      ->14
         18    >   FE_FREE                                                  $9
   28    19        INIT_FCALL                                               'array_search'
         20        INIT_FCALL                                               'max'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $12     
         23        SEND_VAR                                                 $12
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $13     
         26        FETCH_DIM_R                                      ~14     !0, $13
         27        ECHO                                                     ~14
         28        ECHO                                                     '%0A'
   29    29      > RETURN                                                   null

End of function main

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.67 ms | 1403 KiB | 28 Q