3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'hello world'; $cnt = count(array_filter(str_split($str), function ($v) { return ord($v) % 3 == 0; })); echo 'total count- '.$cnt . PHP_EOL; $cnt = array_reduce(str_split($str), function ($c, $v) { return $c + (ord($v) % 3 == 0 ? 1 : 0); }, 0); echo 'total count- '.$cnt . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rCKYp
function name:  (null)
number of ops:  28
compiled vars:  !0 = $str, !1 = $cnt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'hello+world'
    4     1        INIT_FCALL                                               'array_filter'
          2        INIT_FCALL                                               'str_split'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        SEND_VAR                                                 $3
          6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FrCKYp%3A4%240'
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                         $5      
          9        COUNT                                            ~6      $5
         10        ASSIGN                                                   !1, ~6
    5    11        CONCAT                                           ~8      'total+count-+', !1
         12        CONCAT                                           ~9      ~8, '%0A'
         13        ECHO                                                     ~9
    7    14        INIT_FCALL                                               'array_reduce'
         15        INIT_FCALL                                               'str_split'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $10     
         18        SEND_VAR                                                 $10
         19        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FrCKYp%3A7%241'
         20        SEND_VAL                                                 ~11
         21        SEND_VAL                                                 0
         22        DO_ICALL                                         $12     
         23        ASSIGN                                                   !1, $12
    8    24        CONCAT                                           ~14     'total+count-+', !1
         25        CONCAT                                           ~15     ~14, '%0A'
         26        ECHO                                                     ~15
    9    27      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FrCKYp%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rCKYp
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'ord'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        MOD                                              ~2      $1, 3
          5        IS_EQUAL                                         ~3      ~2, 0
          6      > RETURN                                                   ~3
          7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FrCKYp%3A4%240

Function %00%7Bclosure%7D%2Fin%2FrCKYp%3A7%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rCKYp
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $c, !1 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        INIT_FCALL                                               'ord'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $2      
          5        MOD                                              ~3      $2, 3
          6        IS_EQUAL                                                 ~3, 0
          7      > JMPZ                                                     ~4, ->10
          8    >   QM_ASSIGN                                        ~5      1
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~5      0
         11    >   ADD                                              ~6      !0, ~5
         12      > RETURN                                                   ~6
         13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FrCKYp%3A7%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.56 ms | 1405 KiB | 21 Q