3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'plstrim'; $spaces = [ // The horizontal space characters are: "\u{0009}", // Horizontal tab (HT) "\u{0020}", // Space "\u{00A0}", // Non-break space "\u{1680}", // Ogham space mark "\u{180E}", // Mongolian vowel separator "\u{2000}", // En quad "\u{2001}", // Em quad "\u{2002}", // En space "\u{2003}", // Em space "\u{2004}", // Three-per-em space "\u{2005}", // Four-per-em space "\u{2006}", // Six-per-em space "\u{2007}", // Figure space "\u{2008}", // Punctuation space "\u{2009}", // Thin space "\u{200A}", // Hair space "\u{202F}", // Narrow no-break space "\u{205F}", // Medium mathematical space "\u{3000}", // Ideographic space // The vertical space characters are: "\u{000A}", // Linefeed (LF) "\u{000B}", // Vertical tab (VT) "\u{000C}", // Form feed (FF) "\u{000D}", // Carriage return (CR) "\u{0085}", // Next line (NEL) "\u{2028}", // Line separator "\u{2029}" // Paragraph separator ]; foreach($spaces as $s) { $totrim = $str . $s . $s . $s; $trimmed = preg_replace('~\s+$~us', '\1', $totrim); // right-trimming $sname = str_pad(strtoupper(dechex(IntlChar::ord($s))), 4, '0', STR_PAD_LEFT); var_dump([$sname, $totrim, $trimmed]); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 37
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 37
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/s16FF
function name:  (null)
number of ops:  39
compiled vars:  !0 = $str, !1 = $spaces, !2 = $s, !3 = $totrim, !4 = $trimmed, !5 = $sname
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'plstrim'
    5     1        ASSIGN                                                   !1, <array>
   39     2      > FE_RESET_R                                       $8      !1, ->37
          3    > > FE_FETCH_R                                               $8, !2, ->37
   40     4    >   CONCAT                                           ~9      !0, !2
          5        CONCAT                                           ~10     ~9, !2
          6        CONCAT                                           ~11     ~10, !2
          7        ASSIGN                                                   !3, ~11
   41     8        INIT_FCALL                                               'preg_replace'
          9        SEND_VAL                                                 '%7E%5Cs%2B%24%7Eus'
         10        SEND_VAL                                                 '%5C1'
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $13     
         13        ASSIGN                                                   !4, $13
   42    14        INIT_FCALL                                               'str_pad'
         15        INIT_FCALL                                               'strtoupper'
         16        INIT_FCALL                                               'dechex'
         17        INIT_STATIC_METHOD_CALL                                  'IntlChar', 'ord'
         18        SEND_VAR_EX                                              !2
         19        DO_FCALL                                      0  $15     
         20        SEND_VAR                                                 $15
         21        DO_ICALL                                         $16     
         22        SEND_VAR                                                 $16
         23        DO_ICALL                                         $17     
         24        SEND_VAR                                                 $17
         25        SEND_VAL                                                 4
         26        SEND_VAL                                                 '0'
         27        SEND_VAL                                                 0
         28        DO_ICALL                                         $18     
         29        ASSIGN                                                   !5, $18
   43    30        INIT_FCALL                                               'var_dump'
         31        INIT_ARRAY                                       ~20     !5
         32        ADD_ARRAY_ELEMENT                                ~20     !3
         33        ADD_ARRAY_ELEMENT                                ~20     !4
         34        SEND_VAL                                                 ~20
         35        DO_ICALL                                                 
   39    36      > JMP                                                      ->3
         37    >   FE_FREE                                                  $8
   44    38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.01 ms | 1438 KiB | 18 Q