3v4l.org

run code in 300+ PHP versions simultaneously
<?php function stringToArrayOfIntegers($string, $uniqueAndSorted = true, $min = null, $max = null) { $array = array(); if(is_int($string) || is_numeric($string)) { $i = @intval($string); if(is_null($min) || ($i >= $min)) { if(is_null($max) || ($i <= $max)) { $array[] = $i; } } } elseif(is_string($string) && strlen($string) && preg_match('/^\\s*([-+]?\\d+)([\\s,;]+([-+]?\\d+))*\\s*$/', $string)) { foreach(split(' ', trim(preg_replace('/[^\\-\\d ]+/', ' ', $string))) as $n) { if(is_numeric($n)) { $i = @intval($string); if(is_null($min) || ($i >= $min)) { if(is_null($max) || ($i <= $max)) { $array[] = $i; } } } } } if($uniqueAndSorted) { if(version_compare(PHP_VERSION, '5.2.9') >= 0) { $array = array_unique($array, SORT_NUMERIC); } else { $array = array_unique($array); } sort($array, SORT_NUMERIC); } return array(); } var_dump(stringToArrayOfIntegers('1'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kTiGZ
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'stringtoarrayofintegers'
          2        SEND_VAL                                                 '1'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function stringtoarrayofintegers:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 29
Branch analysis from position: 12
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 28
Branch analysis from position: 21
2 jumps found. (Code = 47) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 76
Branch analysis from position: 76
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 97
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 83, Position 2 = 89
Branch analysis from position: 83
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 89
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 97
Branch analysis from position: 28
Branch analysis from position: 25
Branch analysis from position: 28
Branch analysis from position: 20
Branch analysis from position: 29
2 jumps found. (Code = 46) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 39
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 76
Branch analysis from position: 40
2 jumps found. (Code = 77) Position 1 = 53, Position 2 = 75
Branch analysis from position: 53
2 jumps found. (Code = 78) Position 1 = 54, Position 2 = 75
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 74
Branch analysis from position: 58
2 jumps found. (Code = 47) Position 1 = 64, Position 2 = 66
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 74
Branch analysis from position: 67
2 jumps found. (Code = 47) Position 1 = 69, Position 2 = 71
Branch analysis from position: 69
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 74
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 74
Branch analysis from position: 71
Branch analysis from position: 74
Branch analysis from position: 66
Branch analysis from position: 74
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 97
Branch analysis from position: 77
Branch analysis from position: 97
Branch analysis from position: 75
Branch analysis from position: 76
Branch analysis from position: 39
Branch analysis from position: 33
Branch analysis from position: 11
filename:       /in/kTiGZ
function name:  stringToArrayOfIntegers
number of ops:  99
compiled vars:  !0 = $string, !1 = $uniqueAndSorted, !2 = $min, !3 = $max, !4 = $array, !5 = $i, !6 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <true>
          2        RECV_INIT                                        !2      null
          3        RECV_INIT                                        !3      null
    3     4        ASSIGN                                                   !4, <array>
    4     5        TYPE_CHECK                                   16  ~8      !0
          6      > JMPNZ_EX                                         ~8      ~8, ->11
          7    >   INIT_FCALL                                               'is_numeric'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $9      
         10        BOOL                                             ~8      $9
         11    > > JMPZ                                                     ~8, ->29
    5    12    >   BEGIN_SILENCE                                    ~10     
         13        CAST                                          4  ~11     !0
         14        END_SILENCE                                              ~10
         15        ASSIGN                                                   !5, ~11
    6    16        TYPE_CHECK                                    2  ~13     !2
         17      > JMPNZ_EX                                         ~13     ~13, ->20
         18    >   IS_SMALLER_OR_EQUAL                              ~14     !2, !5
         19        BOOL                                             ~13     ~14
         20    > > JMPZ                                                     ~13, ->28
    7    21    >   TYPE_CHECK                                    2  ~15     !3
         22      > JMPNZ_EX                                         ~15     ~15, ->25
         23    >   IS_SMALLER_OR_EQUAL                              ~16     !5, !3
         24        BOOL                                             ~15     ~16
         25    > > JMPZ                                                     ~15, ->28
    8    26    >   ASSIGN_DIM                                               !4
         27        OP_DATA                                                  !5
         28    > > JMP                                                      ->76
   12    29    >   TYPE_CHECK                                   64  ~18     !0
         30      > JMPZ_EX                                          ~18     ~18, ->33
         31    >   STRLEN                                           ~19     !0
         32        BOOL                                             ~18     ~19
         33    > > JMPZ_EX                                          ~18     ~18, ->39
         34    >   INIT_FCALL                                               'preg_match'
         35        SEND_VAL                                                 '%2F%5E%5Cs%2A%28%5B-%2B%5D%3F%5Cd%2B%29%28%5B%5Cs%2C%3B%5D%2B%28%5B-%2B%5D%3F%5Cd%2B%29%29%2A%5Cs%2A%24%2F'
         36        SEND_VAR                                                 !0
         37        DO_ICALL                                         $20     
         38        BOOL                                             ~18     $20
         39    > > JMPZ                                                     ~18, ->76
   13    40    >   INIT_FCALL_BY_NAME                                       'split'
         41        SEND_VAL_EX                                              '+'
         42        INIT_FCALL                                               'trim'
         43        INIT_FCALL                                               'preg_replace'
         44        SEND_VAL                                                 '%2F%5B%5E%5C-%5Cd+%5D%2B%2F'
         45        SEND_VAL                                                 '+'
         46        SEND_VAR                                                 !0
         47        DO_ICALL                                         $21     
         48        SEND_VAR                                                 $21
         49        DO_ICALL                                         $22     
         50        SEND_VAR_NO_REF_EX                                       $22
         51        DO_FCALL                                      0  $23     
         52      > FE_RESET_R                                       $24     $23, ->75
         53    > > FE_FETCH_R                                               $24, !6, ->75
   14    54    >   INIT_FCALL                                               'is_numeric'
         55        SEND_VAR                                                 !6
         56        DO_ICALL                                         $25     
         57      > JMPZ                                                     $25, ->74
   15    58    >   BEGIN_SILENCE                                    ~26     
         59        CAST                                          4  ~27     !0
         60        END_SILENCE                                              ~26
         61        ASSIGN                                                   !5, ~27
   16    62        TYPE_CHECK                                    2  ~29     !2
         63      > JMPNZ_EX                                         ~29     ~29, ->66
         64    >   IS_SMALLER_OR_EQUAL                              ~30     !2, !5
         65        BOOL                                             ~29     ~30
         66    > > JMPZ                                                     ~29, ->74
   17    67    >   TYPE_CHECK                                    2  ~31     !3
         68      > JMPNZ_EX                                         ~31     ~31, ->71
         69    >   IS_SMALLER_OR_EQUAL                              ~32     !5, !3
         70        BOOL                                             ~31     ~32
         71    > > JMPZ                                                     ~31, ->74
   18    72    >   ASSIGN_DIM                                               !4
         73        OP_DATA                                                  !5
   13    74    > > JMP                                                      ->53
         75    >   FE_FREE                                                  $24
   24    76    > > JMPZ                                                     !1, ->97
   25    77    >   INIT_FCALL                                               'version_compare'
         78        SEND_VAL                                                 '8.0.0'
         79        SEND_VAL                                                 '5.2.9'
         80        DO_ICALL                                         $34     
         81        IS_SMALLER_OR_EQUAL                                      0, $34
         82      > JMPZ                                                     ~35, ->89
   26    83    >   INIT_FCALL                                               'array_unique'
         84        SEND_VAR                                                 !4
         85        SEND_VAL                                                 1
         86        DO_ICALL                                         $36     
         87        ASSIGN                                                   !4, $36
         88      > JMP                                                      ->93
   29    89    >   INIT_FCALL                                               'array_unique'
         90        SEND_VAR                                                 !4
         91        DO_ICALL                                         $38     
         92        ASSIGN                                                   !4, $38
   31    93    >   INIT_FCALL                                               'sort'
         94        SEND_REF                                                 !4
         95        SEND_VAL                                                 1
         96        DO_ICALL                                                 
   33    97    > > RETURN                                                   <array>
   34    98*     > RETURN                                                   null

End of function stringtoarrayofintegers

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.89 ms | 1402 KiB | 30 Q