3v4l.org

run code in 500+ 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 = 32
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 32
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/s16FF
function name:  (null)
number of ops:  34
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, ->32
          3    > > FE_FETCH_R                                                   $8, !2, ->32
   40     4    >   CONCAT                                               ~9      !0, !2
          5        CONCAT                                               ~10     ~9, !2
          6        CONCAT                                               ~11     ~10, !2
          7        ASSIGN                                                       !3, ~11
   41     8        FRAMELESS_ICALL_3                preg_replace        ~13     '%7E%5Cs%2B%24%7Eus', '%5C1'
          9        OP_DATA                                                      !3
         10        ASSIGN                                                       !4, ~13
   42    11        INIT_FCALL                                                   'str_pad'
         12        INIT_FCALL                                                   'strtoupper'
         13        INIT_STATIC_METHOD_CALL                                      'IntlChar', 'ord'
         14        SEND_VAR_EX                                                  !2
         15        DO_FCALL                                          0  $15     
         16        FRAMELESS_ICALL_1                dechex              ~16     $15
         17        SEND_VAL                                                     ~16
         18        DO_ICALL                                             $17     
         19        SEND_VAR                                                     $17
         20        SEND_VAL                                                     4
         21        SEND_VAL                                                     '0'
         22        SEND_VAL                                                     0
         23        DO_ICALL                                             $18     
         24        ASSIGN                                                       !5, $18
   43    25        INIT_FCALL                                                   'var_dump'
         26        INIT_ARRAY                                           ~20     !5
         27        ADD_ARRAY_ELEMENT                                    ~20     !3
         28        ADD_ARRAY_ELEMENT                                    ~20     !4
         29        SEND_VAL                                                     ~20
         30        DO_ICALL                                                     
   39    31      > JMP                                                          ->3
         32    >   FE_FREE                                                      $8
   44    33      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
221.96 ms | 2802 KiB | 16 Q