3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'moooopuuuooze'; // The regex matches any character -> . in a capture group () // plus as much identical characters as possible following it -> \1+ $pattern = '/(.)\1+/'; preg_match_all($pattern, $string, $m); // sort by their length // sort by their length usort($m[0], 'length_sort'); function length_sort($a, $b) { return (strlen($a) < strlen($b)) ? 1 : -1; } echo "Longest sequence: " . $m[0][0] . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vM1C1
function name:  (null)
number of ops:  18
compiled vars:  !0 = $string, !1 = $pattern, !2 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'moooopuuuooze'
    6     1        ASSIGN                                                   !1, '%2F%28.%29%5C1%2B%2F'
    8     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
   12     7        INIT_FCALL                                               'usort'
          8        FETCH_DIM_W                                      $6      !2, 0
          9        SEND_REF                                                 $6
         10        SEND_VAL                                                 'length_sort'
         11        DO_ICALL                                                 
   18    12        FETCH_DIM_R                                      ~8      !2, 0
         13        FETCH_DIM_R                                      ~9      ~8, 0
         14        CONCAT                                           ~10     'Longest+sequence%3A+', ~9
         15        CONCAT                                           ~11     ~10, '%0A'
         16        ECHO                                                     ~11
         17      > RETURN                                                   1

Function length_sort:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vM1C1
function name:  length_sort
number of ops:  11
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        STRLEN                                           ~2      !0
          3        STRLEN                                           ~3      !1
          4        IS_SMALLER                                               ~2, ~3
          5      > JMPZ                                                     ~4, ->8
          6    >   QM_ASSIGN                                        ~5      1
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      -1
          9    > > RETURN                                                   ~5
   16    10*     > RETURN                                                   null

End of function length_sort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.94 ms | 1396 KiB | 17 Q