3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ '100010' => '110', '010200' => '1200', '01110' => '1110', ]; foreach ($strings as $subject => $expected) { $actual = preg_replace('/0+(?!^)/', '', $string); printf(" %s -> %s (expected: %s)\n", $subject, $actual, $expected); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 17
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/IPl5V
function name:  (null)
number of ops:  19
compiled vars:  !0 = $strings, !1 = $expected, !2 = $subject, !3 = $actual, !4 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1      > FE_RESET_R                                       $6      !0, ->17
          2    > > FE_FETCH_R                                       ~7      $6, !1, ->17
          3    >   ASSIGN                                                   !2, ~7
   11     4        INIT_FCALL                                               'preg_replace'
          5        SEND_VAL                                                 '%2F0%2B%28%3F%21%5E%29%2F'
          6        SEND_VAL                                                 ''
          7        SEND_VAR                                                 !4
          8        DO_ICALL                                         $9      
          9        ASSIGN                                                   !3, $9
   12    10        INIT_FCALL                                               'printf'
         11        SEND_VAL                                                 '+%25s+-%3E+%25s+%28expected%3A+%25s%29%0A'
         12        SEND_VAR                                                 !2
         13        SEND_VAR                                                 !3
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                                 
    9    16      > JMP                                                      ->2
         17    >   FE_FREE                                                  $6
   13    18      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.71 ms | 1386 KiB | 17 Q