3v4l.org

run code in 500+ PHP versions simultaneously
<?php function ansiSafeWrapper(string $string, int $max = 80) { return preg_replace( "~(?=(?:(?:\\\\x1b\[[0-9;]+m)?.){{$max}})(?:(?:\\\\x1b\[[0-9;]+m)?.){0,$max}\K ~u", PHP_EOL, str_replace(PHP_EOL, ' ', $string) ); } $test = <<<'ANSI' Morbi leo risus, \x1b[34;1mporta ac consectetur\x1b[39;22m ac, vestibulum at eros. Aenean lacinia bibendum nulla sed consectetur. Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean lacinia bibendum nulla sed consectetur. Curabitur blandit tempus porttitor. ANSI; echo ansiSafeWrapper($test);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bjajX
function name:  (null)
number of ops:  6
compiled vars:  !0 = $test
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                       !0, 'Morbi+leo+risus%2C+%5Cx1b%5B34%3B1mporta+ac+consectetur%5Cx1b%5B39%3B22m+ac%2C+vestibulum+at%0Aeros.+Aenean+lacinia+bibendum+nulla+sed+consectetur.+Nullam+id+dolor+id+nibh%0Aultricies+vehicula+ut+id+elit.+Aenean+lacinia+bibendum+nulla+sed+consectetur.%0ACurabitur+blandit+tempus+porttitor.'
   18     1        INIT_FCALL                                                   'ansisafewrapper'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $2      
          4        ECHO                                                         $2
          5      > RETURN                                                       1

Function ansisafewrapper:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bjajX
function name:  ansiSafeWrapper
number of ops:  13
compiled vars:  !0 = $string, !1 = $max
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      80
    5     2        ROPE_INIT                                         5  ~3      '%7E%28%3F%3D%28%3F%3A%28%3F%3A%5C%5Cx1b%5C%5B%5B0-9%3B%5D%2Bm%29%3F.%29%7B'
          3        ROPE_ADD                                          1  ~3      ~3, !1
          4        ROPE_ADD                                          2  ~3      ~3, '%7D%29%28%3F%3A%28%3F%3A%5C%5Cx1b%5C%5B%5B0-9%3B%5D%2Bm%29%3F.%29%7B0%2C'
          5        ROPE_ADD                                          3  ~3      ~3, !1
          6        ROPE_END                                          4  ~2      ~3, '%7D%5CK+%7Eu'
    7     7        FRAMELESS_ICALL_3                str_replace         ~6      '%0A', '+'
          8        OP_DATA                                                      !0
    4     9        FRAMELESS_ICALL_3                preg_replace        ~7      ~2, '%0A'
    7    10        OP_DATA                                                      ~6
         11      > RETURN                                                       ~7
    9    12*     > RETURN                                                       null

End of function ansisafewrapper

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
197.88 ms | 1751 KiB | 14 Q