3v4l.org

run code in 300+ 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:  19
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
    4     2        INIT_FCALL                                               'preg_replace'
    5     3        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'
          4        ROPE_ADD                                      1  ~3      ~3, !1
          5        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'
          6        ROPE_ADD                                      3  ~3      ~3, !1
          7        ROPE_END                                      4  ~2      ~3, '%7D%5CK+%7Eu'
          8        SEND_VAL                                                 ~2
    6     9        SEND_VAL                                                 '%0A'
    7    10        INIT_FCALL                                               'str_replace'
         11        SEND_VAL                                                 '%0A'
         12        SEND_VAL                                                 '+'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $6      
         15        SEND_VAR                                                 $6
    4    16        DO_ICALL                                         $7      
    7    17      > RETURN                                                   $7
    9    18*     > RETURN                                                   null

End of function ansisafewrapper

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.53 ms | 1006 KiB | 16 Q