3v4l.org

run code in 300+ PHP versions simultaneously
<?PHP $str = " Monday Tuesday Wednesday Thursday Friday\nSaturday\tSunday"; function a($str) { return str_word_count($str,1,"!\"#$%&'()*+,./0123456789-:;<=>?@[\]^_`{|}~"); }; function c($str) { return preg_split("/\s+/",trim($str)); }; function d($string){ return array_filter(explode(' ', implode(' ', array_map('trim', explode("\n", $string))))); }; function e($str) { $str = trim($str); $words = array(); $len = strlen($str); $word = ''; for ($i = 0; $i < $len; $i++) { $char = $str[$i]; $ord = ord($char); // Is a character if ($ord > 32 && $ord < 127) { $word .= $char; // It's some sort of whitespace } else { if ($word) { $words[] = $word; } $word = ''; } } if ($word) { $words[] = $word; } return $words; }; function f($str,$return_hash = false) { $str = trim($str); // Word characters are any printable char $words = str_word_count($str,1,"!\"#$%&'()*+,./0123456789-:;<=>?@[\]^_`{|}~"); if ($return_hash) { $ret = array(); $num = sizeof($words); // Odd number of elements, can't build a hash if ($num % 2 == 1) { return array(); } else { // Loop over each word and build a key/value hash for ($i = 0; $i < $num; $i += 2) { $key = $words[$i]; $value = $words[$i + 1]; $ret[$key] = $value; } return $ret; } } else { return $words; } }; a($str); c($str); d($str); e($str); f($str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oaWCV
function name:  (null)
number of ops:  17
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '+Monday+Tuesday+Wednesday+Thursday+Friday%0ASaturday%09Sunday'
   73     1        INIT_FCALL                                               'a'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
   74     4        INIT_FCALL                                               'c'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0          
   75     7        INIT_FCALL                                               'd'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0          
   76    10        INIT_FCALL                                               'e'
         11        SEND_VAR                                                 !0
         12        DO_FCALL                                      0          
   77    13        INIT_FCALL                                               'f'
         14        SEND_VAR                                                 !0
         15        DO_FCALL                                      0          
         16      > RETURN                                                   1

Function a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oaWCV
function name:  a
number of ops:  8
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'str_word_count'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 1
          4        SEND_VAL                                                 '%21%22%23%24%25%26%27%28%29%2A%2B%2C.%2F0123456789-%3A%3B%3C%3D%3E%3F%40%5B%5C%5D%5E_%60%7B%7C%7D%7E'
          5        DO_ICALL                                         $1      
          6      > RETURN                                                   $1
    6     7*     > RETURN                                                   null

End of function a

Function c:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oaWCV
function name:  c
number of ops:  10
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'preg_split'
          2        SEND_VAL                                                 '%2F%5Cs%2B%2F'
          3        INIT_FCALL                                               'trim'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6        SEND_VAR                                                 $1
          7        DO_ICALL                                         $2      
          8      > RETURN                                                   $2
   10     9*     > RETURN                                                   null

End of function c

Function d:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oaWCV
function name:  d
number of ops:  22
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'array_filter'
          2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '+'
          4        INIT_FCALL                                               'implode'
          5        SEND_VAL                                                 '+'
          6        INIT_FCALL                                               'array_map'
          7        SEND_VAL                                                 'trim'
          8        INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '%0A'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $1      
         12        SEND_VAR                                                 $1
         13        DO_ICALL                                         $2      
         14        SEND_VAR                                                 $2
         15        DO_ICALL                                         $3      
         16        SEND_VAR                                                 $3
         17        DO_ICALL                                         $4      
         18        SEND_VAR                                                 $4
         19        DO_ICALL                                         $5      
         20      > RETURN                                                   $5
   14    21*     > RETURN                                                   null

End of function d

Function e:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 11
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 11
Branch analysis from position: 31
Branch analysis from position: 11
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 11
Branch analysis from position: 31
Branch analysis from position: 11
Branch analysis from position: 27
Branch analysis from position: 21
filename:       /in/oaWCV
function name:  e
number of ops:  36
compiled vars:  !0 = $str, !1 = $words, !2 = $len, !3 = $word, !4 = $i, !5 = $char, !6 = $ord
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        INIT_FCALL                                               'trim'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !0, $7
   18     5        ASSIGN                                                   !1, <array>
   19     6        STRLEN                                           ~10     !0
          7        ASSIGN                                                   !2, ~10
   20     8        ASSIGN                                                   !3, ''
   22     9        ASSIGN                                                   !4, 0
         10      > JMP                                                      ->29
   23    11    >   FETCH_DIM_R                                      ~14     !0, !4
         12        ASSIGN                                                   !5, ~14
   24    13        INIT_FCALL                                               'ord'
         14        SEND_VAR                                                 !5
         15        DO_ICALL                                         $16     
         16        ASSIGN                                                   !6, $16
   27    17        IS_SMALLER                                       ~18     32, !6
         18      > JMPZ_EX                                          ~18     ~18, ->21
         19    >   IS_SMALLER                                       ~19     !6, 127
         20        BOOL                                             ~18     ~19
         21    > > JMPZ                                                     ~18, ->24
   28    22    >   ASSIGN_OP                                     8          !3, !5
         23      > JMP                                                      ->28
   31    24    > > JMPZ                                                     !3, ->27
   32    25    >   ASSIGN_DIM                                               !1
         26        OP_DATA                                                  !3
   34    27    >   ASSIGN                                                   !3, ''
   22    28    >   PRE_INC                                                  !4
         29    >   IS_SMALLER                                               !4, !2
         30      > JMPNZ                                                    ~24, ->11
   38    31    > > JMPZ                                                     !3, ->34
   39    32    >   ASSIGN_DIM                                               !1
         33        OP_DATA                                                  !3
   42    34    > > RETURN                                                   !1
   43    35*     > RETURN                                                   null

End of function e

Function f:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 35
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 23
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 23
Branch analysis from position: 33
Branch analysis from position: 23
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oaWCV
function name:  f
number of ops:  37
compiled vars:  !0 = $str, !1 = $return_hash, !2 = $words, !3 = $ret, !4 = $num, !5 = $i, !6 = $key, !7 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
   46     2        INIT_FCALL                                               'trim'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !0, $8
   49     6        INIT_FCALL                                               'str_word_count'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 1
          9        SEND_VAL                                                 '%21%22%23%24%25%26%27%28%29%2A%2B%2C.%2F0123456789-%3A%3B%3C%3D%3E%3F%40%5B%5C%5D%5E_%60%7B%7C%7D%7E'
         10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !2, $10
   51    12      > JMPZ                                                     !1, ->35
   52    13    >   ASSIGN                                                   !3, <array>
   53    14        COUNT                                            ~13     !2
         15        ASSIGN                                                   !4, ~13
   56    16        MOD                                              ~15     !4, 2
         17        IS_EQUAL                                                 ~15, 1
         18      > JMPZ                                                     ~16, ->21
   57    19    > > RETURN                                                   <array>
         20*       JMP                                                      ->34
   60    21    >   ASSIGN                                                   !5, 0
         22      > JMP                                                      ->31
   61    23    >   FETCH_DIM_R                                      ~18     !2, !5
         24        ASSIGN                                                   !6, ~18
   62    25        ADD                                              ~20     !5, 1
         26        FETCH_DIM_R                                      ~21     !2, ~20
         27        ASSIGN                                                   !7, ~21
   64    28        ASSIGN_DIM                                               !3, !6
         29        OP_DATA                                                  !7
   60    30        ASSIGN_OP                                     1          !5, 2
         31    >   IS_SMALLER                                               !5, !4
         32      > JMPNZ                                                    ~25, ->23
   67    33    > > RETURN                                                   !3
         34*       JMP                                                      ->36
   70    35    > > RETURN                                                   !2
   72    36*     > RETURN                                                   null

End of function f

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
194.9 ms | 1410 KiB | 34 Q