3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testValues = [ 'positives' => ['121', '231.45', '77,65', '9.456,77', '4,255.66'], // should pass 'negatives' => ['-121', '-231.45', '-77,65', '-9.456,77', '-4,255.66'], // should pass 'gibberish' => ['231.45a', '7a7,65', 'a9.456,77', '4,255.66a', 'aaaaaa'], // should fail ]; function customIsNumeric(string $value): bool { return is_numeric(str_replace(['.', ','], '', $value)); } foreach ($testValues as $category => $values) { var_dump($category); foreach ($values as $value) { var_dump(customIsNumeric($value)); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 18
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 16
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/UGVe9
function name:  (null)
number of ops:  20
compiled vars:  !0 = $testValues, !1 = $values, !2 = $category, !3 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   14     1      > FE_RESET_R                                       $5      !0, ->18
          2    > > FE_FETCH_R                                       ~6      $5, !1, ->18
          3    >   ASSIGN                                                   !2, ~6
   15     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                                 
   16     7      > FE_RESET_R                                       $9      !1, ->16
          8    > > FE_FETCH_R                                               $9, !3, ->16
   17     9    >   INIT_FCALL                                               'var_dump'
         10        INIT_FCALL                                               'customisnumeric'
         11        SEND_VAR                                                 !3
         12        DO_FCALL                                      0  $10     
         13        SEND_VAR                                                 $10
         14        DO_ICALL                                                 
   16    15      > JMP                                                      ->8
         16    >   FE_FREE                                                  $9
   14    17      > JMP                                                      ->2
         18    >   FE_FREE                                                  $5
   19    19      > RETURN                                                   1

Function customisnumeric:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UGVe9
function name:  customIsNumeric
number of ops:  13
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'is_numeric'
          2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 <array>
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $1      
          7        SEND_VAR                                                 $1
          8        DO_ICALL                                         $2      
          9        VERIFY_RETURN_TYPE                                       $2
         10      > RETURN                                                   $2
   12    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function customisnumeric

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.6 ms | 1009 KiB | 17 Q